Created
March 12, 2023 06:39
-
-
Save skyksandr/fe471e9214460efc48e7ee56c2e20274 to your computer and use it in GitHub Desktop.
How to upgrade local Postgres cluster if you use Postgres.app
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
| # 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