Upgrading to postgresql 9.5 with homebrew is fairly simple. It just takes a few steps. This may seem like a lot, but depending on the size of your database, it should only take a few minutes to do all these steps.

Stop the postgresql server (if using launchctl):

$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Update postgresql

$ brew update && brew upgrade postgresql

Move the old postgresql directory

$ mv /usr/local/var/postgres /usr/local/var/postgres-9.4

Create a new postgresql directory

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

Migrate the data to the 9.5 format

$ pg_upgrade \
	-d /usr/local/var/postgres-9.4 \
	-D /usr/local/var/postgres \
	-b /usr/local/Cellar/postgresql/9.4.5_2/bin \
	-B /usr/local/Cellar/postgresql/9.5.0/bin

Note: You may need to change the versions above to whatever the current versions are.

Start postgresql

$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist


That’s really all there is to it! You can brew cleanup postgresql once you’ve verified that your server works using psql and looking around your tables.