Upgrade PostgreSQL from 12 to 13 with Homebrew
🆙

Upgrade PostgreSQL from 12 to 13 with Homebrew

Tags
Daily
Created
Jan 17, 2021 10:07 PM
Published

@01/17/2021

I wanted to point out some straightforward commands for doing this database upgrade on your Mac, if you, like me, have ignored doing so. This post from Olivier Lacan was a great help and I just wanted to make it even clearer that it's this easy:

brew services stop postgresql
brew postgresql-upgrade-database
brew services start postgresql

Glorious! Here's what the original error looked like for me, for SEO juice and future reference:

💚 pg_ctl -D /usr/local/var/postgres start
waiting for server to start....2021-01-17 17:03:03.686 EST [13710] FATAL:  database files are incompatible with server
2021-01-17 17:03:03.686 EST [13710] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 13.1.
 stopped waiting
pg_ctl: could not start server
Examine the log output

So, I ran the above commands - here's the full output in case you're curious.

I hope that helps someone in the future!

P.S.: Cleanup!

If your app works well once you've upgraded - your "old" Postgres 12 might take up a ton of space:

💚 du -ksh /usr/local/var/postgres.old
672M	/usr/local/var/postgres.old

You can clean that up with:

💚 rm -rf /usr/local/var/postgres.old

¤ @qrush