Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSQL upgrade on Amazon RDS blocked by PostGIS version

Tags:

I'm trying to upgrade my RDS instance from 9.5.4 to 9.6.1, and I'm getting blocked by an error about the PostGIS version needing to be upgraded first.

Database instance is in a state that cannot be upgraded: PreUpgrade checks failed: The instance could not be upgraded because there are one or more databases with an older version of PostGIS installed. Please upgrade all installations of PostGIS and try again.

The highest version of PostGIS supported by RDS 9.5.4 is 2.2.2

alter extension postgis update

yields

NOTICE: version "2.2.2" of extension "postgis" is already installed

I tried upgrading explicitly to the version in 9.6.1

alter extension postgis update to '2.3.0'

Getting

[Err] ERROR: extension "postgis" has no update path from version "2.2.2" to version "2.3.0"

So my question is: how do I upgrade? I suspect I can delete the extension prior to the upgrade and install the new version after, but I don't know what that will do to my data, or if that will properly upgrade my spatial structures or functions.

I have already checked the documentation for any mention of this scenario

like image 477
Jonathan Haglund Avatar asked Mar 06 '17 20:03

Jonathan Haglund


People also ask

Does AWS support PostGIS?

Amazon Relational Database Service (Amazon RDS) for PostgreSQL now supports PostGIS major version 3.1. This new version of PostGIS is available on PostgreSQL versions 13.4, 12.8, 11.13, 10.18, and higher. PostGIS allows you to store, query and analyze geospatial data within a PostgreSQL database.

How do I upgrade PostGIS?

To upgrade PostGIS, you first have to install the latest binaries and then upgrade each database you have PostGIS installed in. For example connect to database you want to upgrade and if you just installed binaries for 2.5. You can upgrade from 2.5 to 3.1, 3.3 etc using this approach.

What version of Postgres does RDS use?

Amazon RDS for PostgreSQL currently supports PostgreSQL 9.6, 10, 11, 12, 13, and 14. Information about the supported minor versions is available in the Amazon RDS User Guide.


1 Answers

Make sure your instance is upgraded to 9.5.4 before upgrading to 9.6.1.

I had this same error on one of my DB instances, but it was on 9.5.2. First I upgraded it to 9.5.4 and then to 9.6.1 and everything worked as expected.

The next instance I tried it on was already on 9.5.4 and got the same message.

So first I did an:

ALTER EXTENSION postgis UPDATE; 

Then upgraded the server

like image 125
Michael Robellard Avatar answered Sep 24 '22 13:09

Michael Robellard