Skip to content

Instantly share code, notes, and snippets.

@phudgins
Last active December 23, 2015 12:49
Show Gist options
  • Save phudgins/6638471 to your computer and use it in GitHub Desktop.
Save phudgins/6638471 to your computer and use it in GitHub Desktop.
Mac Homebrew upgrade postgres from 9.2.4 to 9.3.0
# Unload the launch_ctl (stop the server)
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# Move the data directory
mv /usr/local/var/postgres /usr/local/var/postgres92
# Upgrade postgresql
brew update && brew upgrade postgresql
# Init the new database cluster
initdb /usr/local/var/postgres -E utf8
# Update the old database cluster to the new one
pg_upgrade -b /usr/local/Cellar/postgresql/9.2.4/bin -B /usr/local/Cellar/postgresql/9.3.0/bin -d /usr/local/var/postgres92 -D /usr/local/var/postgres
# Load the launch_ctl (start the server)
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
# For each ruby, uninstall the pg gem
gem uninstall pg
# export ARCHFLAGS env var
export ARCHFLAGS="-arch x86_64"
# For each rails project using pg, reinstall the gem
bundle install
# Verify it works
rails c
# Profit
@robinwhittleton
Copy link

Thanks for this!

@plentz
Copy link

plentz commented Sep 25, 2013

I've posted a few more details here http://tautt.com/upgrading-postgresql-9-2-to-9-3/ :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment