Skip to content

Instantly share code, notes, and snippets.

@skyksandr
Created March 12, 2023 06:39
Show Gist options
  • Select an option

  • Save skyksandr/fe471e9214460efc48e7ee56c2e20274 to your computer and use it in GitHub Desktop.

Select an option

Save skyksandr/fe471e9214460efc48e7ee56c2e20274 to your computer and use it in GitHub Desktop.
How to upgrade local Postgres cluster if you use Postgres.app
# You need multi-version installation for doing this
# In the example below I upgrade from Postgres 14 to Postgres 15
# create folder for new cluster
mkdir -p ~/Library/Application\ Support/Postgres/postgresql@15
# initialize cluster
/Applications/Postgres.app/Contents/Versions/15/bin/initdb -D ~/Library/Application\ Support/Postgres/postgresql@15 --encoding=UTF-8 --locale=en_US.UTF-8 -U postgres
# if it errors with
# initdb: error: directory "~/Library/Application Support/Postgres/postgresql@15" exists but is not empty
# then probably macos created .DS_store there. Run command below and repeat
rm ~/Library/Application\ Support/Postgres/postgresql@15/.DS_Store
# After it is place:
/Applications/Postgres.app/Contents/Versions/15/bin/pg_upgrade -b /Applications/Postgres.app/Contents/Versions/14/bin -B /Applications/Postgres.app/Contents/Versions/15/bin -d ~/Library/Application\ Support/Postgres/postgresql@14 -D ~/Library/Application\ Support/Postgres/postgresql@15 -U postgres -v
# Based official guide: https://postgresapp.com/documentation/migrating-data.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment