Search code examples
postgresqlamazon-web-servicesamazon-rdspostgis

How to upgrade AWS RDS Postgres instance from 14 to 15 with postgis?


AWS added support for Postgres 15.2. Upgrading to this version with postgis extension enabled fails with this error message:

The instance could not be upgraded because there are one or more databases with an older version of PostGIS extension or its dependent extensions (address_standardizer, address_standardizer_data_us, postgis_tiger_geocoder, postgis_topology, postgis_raster) installed. Please upgrade all installations of PostGIS and drop its dependent extensions and try again.

The RDS instance has postgis 3.1.7 installed, and there is no path to upgrade the extension. Running exact upgrade command ALTER EXTENSION postgis UPDATE TO "3.1.8"; results in

extension "postgis" has no update path from version "3.1.7" to version "3.1.8"

Running SELECT postgis_extensions_upgrade(); command which should upgrade the extension results in:

Upgrade completed, run SELECT postgis_full_version(); for details

, but the version after running SELECT postgis_full_version(); returns

POSTGIS="3.1.7 aafe1ff" [EXTENSION] PGSQL="140" GEOS="3.9.1-CAPI-1.14.2" PROJ="8.0.1" LIBXML="2.9.1" LIBJSON="0.15" LIBPROTOBUF="1.3.2" WAGYU="0.5.0 (Internal)"

The postgis_raster extension is broken, and we are not using this, nor any other postgis extension. Only the core postgis extension.

Is there a way to upgrade the RDS instance to postgres. 15 without dropping the postgis extension?


Solution

  • Good news, the normal upgrade workflow is now working:

    1. Upgrade Postgres to 14.8 (newly available)
    2. Upgrade PostGIS to version 3.3.2 (SELECT postgis_extensions_upgrade();)
    3. Upgrade Postgres to 15.3