Skip to content

Instantly share code, notes, and snippets.

@daz
Created September 23, 2022 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daz/477190328f5f20121c26c42ef8fbedbc to your computer and use it in GitHub Desktop.
Save daz/477190328f5f20121c26c42ef8fbedbc to your computer and use it in GitHub Desktop.
Upgrading postgresql 12 to 14 homebrew with postgis
brew install postgresql
brew services stop postgresql
pg_upgrade --old-bindir=/opt/homebrew/opt/postgresql@12/bin \
--new-bindir=/opt/homebrew/opt/postgresql@14/bin \
--old-datadir=/opt/homebrew/var/postgresql@12 \
--new-datadir=/opt/homebrew/var/postgres \
--check
# If you're getting non-empty database errors for the new database, rename the directory to a backup and init a new db:
mv /opt/homebrew/var/postgres /opt/homebrew/var/postgres_backup
# Locale needs to match the old data
initdb --locale="en_US.UTF-8" -D /opt/homebrew/var/postgres
# Might need to do this
/opt/homebrew/opt/postgresql@14/bin/pg_resetwal /opt/homebrew/var/postgres
# Needed to run this on the @12 database as a superuser
# https://postgis.net/2022/08/25/tip-upgrading-postgis-sfcgal/
ALTER EXTENSION postgis UPDATE;
SELECT postgis_extensions_upgrade();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment