This document briefly describes how to upgrade PostgreSQL from 9.4.5 to 9.5 and assumes the installation was done with Homebrew. Upgrades between other versions should be similar.
(original source: http://stackoverflow.com/a/27624397/63347)
pg_ctl stop -w -D /usr/local/var/postgres
brew upgrade postgresql
initdb /usr/local/var/postgres9.5 -E utf8
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.5 \
-b /usr/local/Cellar/postgresql/9.4.5/bin/ \
-B /usr/local/Cellar/postgresql/9.5.0/bin/
cd /usr/local/var
mv postgres postgres9.4
mv postgres9.5 postgres
pg_ctl start -D /usr/local/var/postgres -w -l /usr/local/var/postgres/postgres-server.log