Last active
December 8, 2022 02:10
-
-
Save rgreenjr/3932071 to your computer and use it in GitHub Desktop.
PostgreSQL Upgrading
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
# Taken from http://robots.thoughtbot.com/post/33706558963/migrating-data-from-an-upgraded-postgres | |
# | |
# Note: these steps assume installation with Homebrew. | |
# Initialize a new database, adding a .new suffix to the directory that Homebrew recommends. | |
initdb /usr/local/var/postgres.new -E utf8 | |
# Run the upgrade script, providing the correct paths for the various flags. | |
pg_upgrade \ | |
-b /usr/local/Cellar/postgresql/9.1.4/bin \ | |
-B /usr/local/Cellar/postgresql/9.2.1/bin \ | |
-d /usr/local/var/postgres \ | |
-D /usr/local/var/postgres.new | |
# Put the data in the correct place. | |
rm -rf /usr/local/var/postgres | |
mv /usr/local/var/postgres.new /usr/local/var/postgres | |
# If you’ve set up launchd to run Postgres automatically, | |
# everything should be up and running! Otherwise, check out the | |
# documentation with brew info postgres to read how to have OS X | |
# manage postgres for you. | |
####### | |
# Alternatively, if you’ve just upgraded Postgres with Homebrew and | |
# Postgres won’t start, as long as you don’t care about any data stored locally: | |
brew remove --force postgresql | |
rm -rf /usr/local/var/postgres/ | |
brew install postgresql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment