Upgrading PostGIS v3.2
This section walks you through the following upgrade examples for RHEL/CentOS 7 platforms:
- Example 1: Upgrading from PostGIS version 3.1 to 3.2
- Example 2: Upgrading from PostGIS versions 2.5 or later to 3.1.4 on the same EDB Postgres Advanced Server version
- Example 3: Upgrading from PostGIS versions earlier than 2.5 to 3.1.4 on a different EDB Postgres Advanced Server version
Example 1: Upgrading from PostGIS version 3.1 to 3.2
The following example walks you through upgrading from PostGIS version 3.1 to version 3.2 for EDB Postgres Advanced Server 14.
To avoid accidental upgrades, PostGIS version 3.1 and 3.2 use different package names. So, upgrading to version 3.2 requires that you first uninstall version 3.1. Once you install version 3.2, you can upgrade the PostGIS extensions.
Create the PostGIS extensions in PostGIS version 3.1, if you haven't already. For instructions, see Creating extensions.
Uninstall PostGIS version 3.1.
For EPAS version 14:
yum -y erase edb-as14-postgis3
For older versions of EDB Postgres Advanced Server:
yum erase edb-as<xx>-postgis3
Where
<xx>
is the version of EDB Postgres Advanced Server.For more information, see Uninstalling PostGIS.
Install PostGIS version 3.2. For instructions, see Installing PostGIS on RHEL 7/OL 7 x86.
Upgrade the PostGIS extensions using the following command:
Note
If you first upgraded from a PostGIS version earlier than 2.5 to PostGIS version 3.1, then you must
DROP
thepostgis_raster extension
before executing the command.SELECT postgis_extensions_upgrade();
OutputNOTICE: Updating extension postgis from 3.1.4 to 3.2.1 NOTICE: Updating extension postgis_sfcgal from 3.1.4 to 3.2.1 NOTICE: Updating extension postgis_raster from 3.1.4 to 3.2.1 NOTICE: Updating extension postgis_topology from 3.1.4 to 3.2.1 NOTICE: Updating extension postgis_tiger_geocoder from 3.1.4 to 3.2.1 postgis_extensions_upgrade ------------------------------------------------------------------- Upgrade completed, run SELECT postgis_full_version(); for details (1 row)
Example 2: Upgrading from PostGIS versions 2.5 or later to 3.1.4 on the same EDB Postgres Advanced Server version
The following example walks you through the process of upgrading from PostGIS version 2.5.5 to PostGIS version 3.1.4 for EDB Postgres Advanced Server version 12.
Note
It is assumed that you have already created extensions for PostGIS version 2.5.5 as described in Creating extensions and EDB Advanced Server 12 service is running.
To upgrade PostGIS version 2.5.5 to PostGIS version 3.1.4 for EDB Postgres Advanced Server 12, assume the superuser privileges and invoke the following command:
yum upgrade edb-as12-postgis-3.1.4 -y
To update extensions, switch to
enterprisedb
user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:edb=# alter extension postgis update to '3.1.4'; WARNING: unpackaging raster WARNING: PostGIS Raster functionality has been unpackaged HINT: type `SELECT postgis_extensions_upgrade();` to finish the upgrade. After upgrading, if you want to drop raster, run: DROP EXTENSION postgis_raster; ALTER EXTENSION
edb=# alter extension address_standardizer update to '3.1.4'; ALTER EXTENSION
edb=# SELECT postgis_extensions_upgrade(); NOTICE: Updating extension postgis_sfcgal from 2.5.5 to 3.1.4 NOTICE: Packaging extension postgis_raster NOTICE: Updating extension postgis_topology from 2.5.5 to 3.1.4 NOTICE: Updating extension postgis_tiger_geocoder from 2.5.5 to 3.1.4 postgis_extensions_upgrade ------------------------------------------------------------------- Upgrade completed, run SELECT postgis_full_version(); for details (1 row)
Example 3: Upgrading from PostGIS versions earlier than 2.5 to 3.1.4 on a different EDB Postgres Advanced Server version
The following example walks you through the process of upgrading PostGIS version 2.4.6 for EDB Postgres Advanced Server 10 to PostGIS version 3.1.4 for EDB Postgres Advanced Server version 14:
Step 1 — Upgrade to PostGIS 3.1.1. This is an intermediate step required to resolve dependency issues.
Step 2 — Upgrade to PostGIS 3.1.4.
Step 3 — Upgrade EDB Postgres Advanced Server version 10 to 14.
It is assumed that you have already created extensions for the PostGIS version earlier than 2.5.5 as described in Creating extensions and EDB Advanced Server 10 service is running.
When the PostGIS data has a dependency on the raster functions, upgrading to PostGIS version 3.1.4 requires dumping and reloading the data.
Step 1 — To upgrade PostGIS version 2.4.6 to 3.1.4, you need to upgrade it to 3.1.1 first:
Navigate to the bin directory of EDB Advanced Server 10:
cd /usr/edb/as10/bin/
Assume the superuser privileges and invoke the following command to upgrade to PostGIS version 3.1.1:
yum upgrade edb-as10-postgis-3.1.1 -y
Note
See the Installing PostGIS on a Debian/Ubuntu Host section for information about Debian platform commands.
To update extensions, switch to
enterprisedb
user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:edb=# alter extension postgis update to '3.1.1'; WARNING: unpackaging raster WARNING: PostGIS Raster functionality has been unpackaged HINT: type `SELECT postgis_extensions_upgrade();` to finish the upgrade. After upgrading, if you want to drop raster, run: DROP EXTENSION postgis_raster; ALTER EXTENSION
edb=# alter extension address_standardizer update to '3.1.1'; ALTER EXTENSION
edb=# SELECT postgis_extensions_upgrade();
OutputNOTICE: Updating extension postgis_sfcgal from 2.4.6 to 3.1.1 NOTICE: Packaging extension postgis_raster NOTICE: Updating extension postgis_topology from 2.4.6 to 3.1.1 NOTICE: Updating extension postgis_tiger_geocoder from 2.4.6 to 3.1.1 postgis_extensions_upgrade ------------------------------------------------------------------- Upgrade completed, run SELECT postgis_full_version(); for details (1 row)
Step 2 — Upgrade to PostGIS version 3.1.4:
To upgrade PostGIS version 3.1.1 to 3.1.4, invoke the following command for EDB Postgres Advanced Server 10:
yum upgrade edb-as10-postgis-3.1.4 -y
To update extensions, switch to
enterprisedb
user and execute the following commands:edb=# alter extension postgis update to '3.1.4'; WARNING: unpackaging raster WARNING: PostGIS Raster functionality has been unpackaged HINT: type `SELECT postgis_extensions_upgrade();` to finish the upgrade. After upgrading, if you want to drop raster, run: DROP EXTENSION postgis_raster; ALTER EXTENSION
With PostGIS version 3.1.4, the return type of the raster functions has changed, which requires dropping and creating the raster extension as part of the upgrade process.
edb=# drop extension postgis_raster; DROP EXTENSION
edb=# SELECT postgis_extensions_upgrade(); NOTICE: Updating extension postgis_sfcgal from 3.1.1 to 3.1.4 NOTICE: Updating extension postgis_topology from 3.1.1 to 3.1.4 NOTICE: Updating extension postgis_tiger_geocoder from 3.1.1 to 3.1.4 postgis_extensions_upgrade ------------------------------------------------------------------- Upgrade completed, run SELECT postgis_full_version(); for details (1 row)
edb=# alter extension address_standardizer update to '3.1.4'; ALTER EXTENSION
Quit and re-open the psql client session:
edb=# \q ./psql -d edb -p 5444
edb=# create extension postgis_raster; CREATE EXTENSION
Step 3 — Upgrade EDB Postgres Advanced Server version 10 to 14:
Assume the superuser privileges to stop the EDB Postgres Advanced Server 10 service:
systemctl stop edb-as-10
Install the EDB Postgres Advanced Server version 14:
yum install edb-as14-server -y
Navigate to the bin directory of EDB Advanced Server 14 and initialize the cluster:
cd /usr/edb/as14/bin/ ./edb-as-14-setup initdb
Install the PostGIS version 3.1.4 for EDB Postgres Advanced Server version 14.0:
yum install edb-as14-postgis3-3.1.4 -y
Assume the superuser privileges to stop the EDB Postgres Advanced Server 14.0 service:
systemctl stop edb-as-14
Switch to
enterprisedb
user and create atemp
folder:su enterprisedb cd $(mktemp -d)
Execute the following commands to check cluster compatibility and consistency, as well as to perform the upgrade.
bash-4.2$ /usr/edb/as14/bin/pg_upgrade -d /var/lib/edb/as10/data/ -D /var/lib/edb/as14/data/ -U enterprisedb -b /usr/edb/as10/bin/ -B /usr/edb/as14/bin/ -p 5444 -P 5445 -c Performing Consistency Checks ----------------------------- Checking cluster versions ok Checking database user is the install user ok Checking database connection settings ok Checking for prepared transactions ok Checking for reg* data types in user tables ok Checking for contrib/isn with bigint-passing mismatch ok Checking for tables WITH OIDS ok Checking for invalid "sql_identifier" user columns ok Checking for invalid "unknown" user columns ok Checking for hash indexes ok Checking for presence of required libraries ok Checking database user is the install user ok Checking for prepared transactions ok Checking for new cluster tablespace directories ok Clusters are compatible
bash-4.2$ /usr/edb/as14/bin/pg_upgrade -d /var/lib/edb/as10/data/ -D /var/lib/edb/as14/data/ -U enterprisedb -b /usr/edb/as10/bin/ -B /usr/edb/as14/bin/ -p 5444 -P 5445 --link Performing Consistency Checks ----------------------------- Checking cluster versions ok Checking database user is the install user ok Checking database connection settings ok Checking for prepared transactions ok Checking for reg* data types in user tables ok Checking for contrib/isn with bigint-passing mismatch ok Checking for tables WITH OIDS ok Checking for invalid "sql_identifier" user columns ok Checking for invalid "unknown" user columns ok Creating dump of global objects ok Creating dump of database schemas ok Checking for presence of required libraries ok Checking database user is the install user ok Checking for prepared transactions ok Checking for new cluster tablespace directories ok If pg_upgrade fails after this point, you must re-initdb the new cluster before continuing. Performing Upgrade Analyzing all rows in the new cluster ok Freezing all rows in the new cluster ok Deleting files from new pg_xact ok Copying old pg_clog to new server ok Setting next transaction ID and epoch for new cluster ok Deleting files from new pg_multixact/offsets ok Copying old pg_multixact/offsets to new server ok Deleting files from new pg_multixact/members ok Copying old pg_multixact/members to new server ok Setting next multixact ID and offset for new cluster ok Resetting WAL archives ok Setting frozenxid and minmxid counters in new cluster ok Restoring global objects in the new cluster ok Restoring database schemas in the new cluster ok Adding ".old" suffix to old global/pg_control ok If you want to start the old cluster, you will need to remove the ".old" suffix from /var/lib/edb/as9.6/data/global/pg_control.old. Because "link" mode was used, the old cluster cannot be safely started once the new cluster has been started. Linking user relation files ok Setting next OID for new cluster ok Sync data directory to disk ok Creating script to analyze new cluster ok Creating script to delete old cluster ok Checking for hash indexes ok Upgrade Complete Optimizer statistics are not transferred by pg_upgrade so, once you start the new server, consider running: ./analyze_new_cluster.sh Running this script will delete the old cluster's data files: ./delete_old_cluster.sh
Assume the superuser privileges, navigate to the
bin
directory of EDB Postgres Advanced Server 14, and start the service:cd /usr/edb/as14/bin/ systemctl start edb-as-14
To update extensions, switch to
enterprisedb
user, connect to the database (where you have already created extensions) with the psql client application, and execute the following commands:su enterprisedb ./psql -d edb -p 5444 edb=# SELECT PostGIS_Extensions_Upgrade();
OutputNOTICE: Updating extension postgis 3.1.4 postgis_extensions_upgrade ------------------------------------------------------------------- Upgrade completed, run SELECT postgis_full_version(); for details (1 row)