Last active
October 1, 2024 18:51
-
-
Save lprimak/9de02cf32fd656c745bfe67440b1fe1d to your computer and use it in GitHub Desktop.
How to upgrade postgres
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
Assume the new version is 17, old is 16 | |
* If new postgres is not available in code, make sure Tap petere/postgresql exsists | |
* Do not uninstall the old database version until the end | |
(admin) brew install postgresql@17 | |
stop the database (as postgres user) | |
(postgres) $ pg_ctl -mf stop | |
new_major=17 | |
new_minor=0 | |
old_major=16 | |
old_minor=4 | |
/opt/homebrew/Cellar/postgresql@$new_major/$new_major.$new_minor/bin/initdb ~/var/postgres_new \ | |
-U admin --locale=C --encoding=UTF8 | |
LC_ALL=C /opt/homebrew/Cellar/postgresql@$new_major/$new_major.$new_minor/bin/pg_upgrade \ | |
-b /opt/homebrew/Cellar/postgresql@$old_major/$old_major.$old_minor/bin \ | |
-B /opt/homebrew/Cellar/postgresql@$new_major/$new_major.$new_minor/bin \ | |
-d ~/var/postgres -D ~/var/postgres_new -U admin | |
migrate ~/var/postgres_new/pg_hba.conf and ~/var/postgres_new/postgresql.conf manually | |
mv ~/var/postgres ~/var/postgres_old; mv ~/var/postgres_new ~/var/postgres | |
start new db: pg_ctl start | |
rm -rf ~/var/postgres_old | |
(admin) | |
brew uninstall postgresql@16 | |
brew link -f postgresql@17 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment