Skip to content

Instantly share code, notes, and snippets.

@brookr
Last active December 19, 2015 10:09
Show Gist options
  • Save brookr/5937843 to your computer and use it in GitHub Desktop.
Save brookr/5937843 to your computer and use it in GitHub Desktop.
Upgrading Postgresql from 9.2 to 9.3.1

Make a temporary home for the new database

mkdir -p /usr/local/var/postgres9.3

Tell postgres to set up the new database

initdb /usr/local/var/postgres9.3 -E 'UTF-8' --lc-collate='en_US.UTF-8' --lc-ctype='en_US.UTF-8'

Migrate the data

pg_upgrade -d /usr/local/var/postgres9.2/ -D /usr/local/var/postgres9.3/ -b /usr/local/Cellar/postgresql/9.2.1/bin/ -B /usr/local/Cellar/postgresql/9.3.1/bin/ -v

Make the new db the canonical db

ln -s /usr/local/var/postgres9.3/ /usr/local/var/postgres

Delete old cluster data:

./delete_old_cluster.sh

Delete unneeded helper files

rm analyze_new_cluster.sh delete_old_cluster.sh

Restart the postgres daemon

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Now reload pg gem for every ruby/gemset...

gem uninstall pg && gem install pg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment