How to upgrade your Postgres database tables

I made a booboo the other day. I did brew upgrade instead of brew update! Oops.

The upgrade command updates everything Brew has installed, whereas the update command only updates Brew itself. The result - stuff broke and tears were shed.

The main problem was that my local installation of Postgres got upgraded from 10 to 11. I have this installed locally as I run the Nexmo Developer Platform (NDP) locally for testing documentation, and metadata is stored in the Postgres database. I first realized something was wrong when NDP stopped working. My existing NDP database was not compatible with the new version of Postgres Brew had helpfully installed.

After some panicking and being talked off the ledge by team members, the solution turned out to be quite easy, but as I have the memory of a sieve I thought I'd better make a note here. You might also run into this issue.

So, you can just upgrade your database tables to be compatible with the latest version you have installed:

brew postgresql-upgrade-database

That does the trick!

You also might need to start and stop the server manually which you can do with:

pg_ctl -D /usr/local/var/postgres start
pg_ctl -D /usr/local/var/postgres stop

Good luck!