Last active
November 25, 2025 21:33
-
-
Save chapmanjacobd/3752a34aa3e53c52a4158f66f531c62a to your computer and use it in GitHub Desktop.
Fedora 41 to 43 postgresql 16 to 18 with postgis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| There was a lot of failed attempts* (see below) but what worked for me went something like this: | |
| p$ = sudo su - postgres | |
| --- | |
| Install the PGDG repo https://www.postgresql.org/download/linux/redhat/ | |
| # dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/F-43-x86_64/pgdg-fedora-repo-latest.noarch.rpm | |
| Find the version of postgres to install | |
| # dnf repoquery --disablerepo="*" --enablerepo=pgdg17 postgres\* | |
| # sudo dnf install postgresql17-0:17.7-1PGDG.f43.x86_64 postgresql17-contrib-0:17.7-1PGDG.f43.x86_64 postgresql17-libs-0:17.7-1PGDG.f43.x86_64 postgis36_16 ... | |
| For me I needed postgres 16 from PGDG because the Fedora repo's postgres16 wasn't picking up PGDG's postgis36_16 and postgis36_17 | |
| # systemctl start postgresql-16.service | |
| p$ /usr/pgsql-16/bin/psql | |
| For me I needed to fix a few things before upgrading to pg 17 | |
| SELECT datname, datcollversion FROM pg_database; | |
| Run for each database: REINDEX DATABASE postgres; ALTER DATABASE postgres REFRESH COLLATION VERSION; | |
| DROP AGGREGATE IF EXISTS public.random(anyelement); | |
| DROP FUNCTION IF EXISTS public._final_random(anyarray); | |
| ALTER EXTENSION postgis UPDATE; | |
| # systemctl stop postgresql-16.service | |
| p$ /usr/bin/postgresql-setup --initdb | |
| p$ /usr/pgsql-17/bin/pg_upgrade -b /usr/pgsql-16/bin/ -d 16/data/ -D data/ | |
| # systemctl start postgresql-17.service | |
| p$ /usr/pgsql-17/bin/psql < update_extensions.sql | |
| # systemctl stop postgresql-17.service | |
| p$ /usr/pgsql-17/bin/pg_checksums -D /var/lib/pgsql/17/data/ -e -P | |
| # sudo dnf install postgresql-server postgis postgis-upgrade postgresql-upgrade postgresql-contrib postgresql-plpython3 postgis-upgrade --allowerasing | |
| p$ postgresql-setup --upgrade | |
| p$ cp /var/lib/pgsql/16/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf | |
| # systemctl start postgresql.service | |
| p$ psql < update_extensions.sql | |
| p$ vacuumdb --all --analyze-in-stages | |
| Done! | |
| # dnf remove postgresql17\* postgresql16\* | |
| --- | |
| *Errors like this: | |
| WARNING: database "city" has a collation version mismatch | |
| DETAIL: The database was created using collation version 2.40, but the operating system provides version 2.42. | |
| HINT: Rebuild all objects in this database that use the default collation and run ALTER DATABASE city REFRESH COLLATION VERSION, or build PostgreSQL with the right library version. | |
| ok | |
| Creating dump of global objects ok | |
| Creating dump of database schemas | |
| postgres | |
| *failure* | |
| pg_restore: error: could not execute query: ERROR: function pg_catalog.array_append(anyarray, anyelement) does not exist | |
| Command was: CREATE AGGREGATE "public"."random"("anyelement") ( | |
| SFUNC = "pg_catalog"."array_append", | |
| STYPE = "anyarray", | |
| INITCOND = '{}', | |
| FINALFUNC = "public"."_final_random" | |
| ); | |
| 2025-11-25 20:58:08.818 UTC [24931] ERROR: could not access file "$libdir/postgis-3": No such file or directory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment