launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Rename the old version and update PostgreSQL
mv /usr/local/var/postgres /usr/local/var/postgres91
brew update
brew upgrade postgresql
Init PostgreSQL
initdb /usr/local/var/postgres -E utf8
Update old DBs
pg_upgrade -b /usr/local/Cellar/postgresql/<old.version>/bin -B /usr/local/Cellar/postgresql/<new.version>/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
Copy Homebrew agent and start server
cp /usr/local/Cellar/postgresql/<version>/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Stop it manually
pg_ctl -D /usr/local/var/postgres stop -s -m fast
Start/Stop via launchd configuration
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Create new DB
createdb mydb