Skip to content

Instantly share code, notes, and snippets.

@koyedele
Last active February 17, 2016 04:58
Show Gist options
  • Save koyedele/54a4fb62a1cb91c1a943 to your computer and use it in GitHub Desktop.
Save koyedele/54a4fb62a1cb91c1a943 to your computer and use it in GitHub Desktop.
Upgrade Postgres 9.4 to 9.5 (Homebrew)
These instructions are taken from: Keita's Blog - https://kkob.us/2016/01/09/homebrew-and-postgresql-9-5/
1. Turn PostgreSQL off first, just in case:
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
2. Update PostgreSQL itself:
$ brew update && brew upgrade postgresql
3. Make a new, pristine 9.5 database:
$ initdb /usr/local/var/postgres9.5 -E utf8
4. Migrate the data to the new 9.5 database:
$ pg_upgrade \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.5 \
-b /usr/local/Cellar/postgresql/9.4.5_2/bin/ \
-B /usr/local/Cellar/postgresql/9.5.0/bin/ \
-v
5. Move 9.5 data directory back to where PostgreSQL expects it to be:
$ mv /usr/local/var/postgres /usr/local/var/postgres9.4
$ mv /usr/local/var/postgres9.5 /usr/local/var/postgres
6. Start PostgreSQL back up!
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
** Note: If you’re using the pg gem for Rails, you should recompile:
$ gem uninstall pg
$ gem install pg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment