Skip to content

Instantly share code, notes, and snippets.

@dmdeller
Forked from joho/gist:3735740
Last active April 18, 2016 16:11
Show Gist options
  • Save dmdeller/de8c96d7ff99300dcca1df762aec0479 to your computer and use it in GitHub Desktop.
Save dmdeller/de8c96d7ff99300dcca1df762aec0479 to your computer and use it in GitHub Desktop.
PostgreSQL 9.2 upgrade steps

Steps to upgrade a database from PostgreSQL 9.4 to PostgreSQL 9.5 using Homebrew (Mac OS X)

Notes:

  • I don't use launchd to run Postgres.
  • I don't have Homebrew installed in /usr/local, so I'm using commands that should work regardless of where it is installed.

This assumes you have already upgraded to 9.5 and got the fatal error trying to use your 9.4 database.

We need to have both 9.4 and 9.5 installed, so reinstall the old version.

brew unlink postgresql
brew install homebrew/versions/postgresql94
brew unlink postgresql94
brew link postgresql

Back up the old database.

mv $(brew --prefix)/var/postgres $(brew --prefix)/postgres94

Create a new database.

initdb /usr/local/var/postgres -E utf8

Run pg_upgrade, which effectively copies data from the old 9.4 database to the new, blank 9.5 one. This requires binaries for both 9.4 and 9.5 to be specified.

pg_upgrade -b $(brew --cellar)/postgresql94/9.4.5/bin -B $(brew --cellar)/postgresql/9.5.1/bin -d $(brew --prefix)/var/postgres94 -D $(brew --prefix)/var/postgres

Now you should be able to run 9.5 as normal.

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