Mark Longair
Mark Longair

Reputation: 467033

How can I restore a database dump from an old version of PostGIS on a system with a newer version?

I've got a database dump of a PostGIS database from PostgreSQL 9.1 + PostGIS 1.5.3, which I'm trying to restore on a system with PostgreSQL 9.5 + PostGIS 2.2.1.

After creating the new database, I made it into a PostGIS database with:

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

However, on restoring into this new database, I get the following error (among many others):

ERROR:  function ndims(geometry) does not exist
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Is there anything I can do to import the old database dump?

Upvotes: 1

Views: 745

Answers (1)

Mark Longair
Mark Longair

Reputation: 467033

PostGIS appears to be bundled with some scripts to help restore from database dumps from earlier versions. So, after creating the PostGIS tables and functions with:

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;

You can do:

psql mydatabase < /usr/share/postgresql/9.5/contrib/postgis-2.2/legacy_minimal.sql

Then the database restore works without the ndims error - there are many other errors for functions, etc. that are already defined, but those seem to be ignorable.

Upvotes: 1

Related Questions