Forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Last active
March 21, 2018 16:48
-
-
Save armilam/b7b0dfd099307298ff5196cc7893c52c to your computer and use it in GitHub Desktop.
Upgrade PostgreSQL using Homebrew (macOS)
This file contains 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
# Install the latest version of postgresql via Homebrew | |
brew upgrade postgresql | |
# After doing that, I needed to upgrade my existing database | |
# Need to have both the old and new version of postgresql installed. The example here uses 9.6.1 and 10.3. | |
brew unlink postgresql | |
brew switch postgresql 10.3 | |
brew link postgresql | |
# init new database using 10.0 | |
initdb /usr/local/var/postgres10.3 -E utf8 | |
# finally the actual upgrade | |
# -b is the old binary dir, -B is the new binary dir | |
# -d is the old data dir, -D is the new data dir | |
pg_upgrade -b /usr/local/Cellar/postgresql/9.6.1/bin -B /usr/local/Cellar/postgresql/10.3/bin -d /usr/local/var/postgres9.6 -D /usr/local/var/postgres10.3 | |
# Then link the new postgres instance | |
rm /usr/local/bin/postgresql | |
ln -s /usr/local/var/postgres10.3 /usr/local/bin/postgres | |
# start 10.3 to check that upgrade works | |
pg_ctl -D /usr/local/bin/postgres -l logfile start | |
# cleanup if upgrade was successful | |
brew uninstall postgresql@9.6 | |
rm -rf /usr/local/var/postgres9.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment