Moving to Postgres 16.0
This morning I noticed that not only was Postgres 14.9 out, they had released 15.x and even 16.0. It's unusual for me to be a full major version behind on my main laptop, but to be two was just something that had to be corrected.
Several months ago, it was clear that the official Postgres builds were no longer being done by the Postgres group, and so the support for 15.0 wasn't in Homebrew. I figured it'd just be a little bit, and then things would start back up again. But that was not the case. What happened, instead, was that the Homebrew volunteers took it upon themselves to build the packages for 14.x, 15, and now 16.
So let's write this all down so it's easy to do next time we change a major version of Postgres. Start by saving everything in all the databases:
$ pg_dumpall > dump.sql $ brew services stop postgresql@14
Now we can wipe out the old install and it's data:
$ brew uninstall postgresql@14 $ rm -rf /opt/homebrew/var/postgresql@14
Now we install the new version, start it, and load back up the data:
$ brew install postgresql@16 $ brew services start postgresql@16 $ psql -d postgres -f dump.sql $ psql -l
If the command psql doesn't show up in the path, just relink the package:
$ brew link postgresql@16
Then it should be in the right spot.
At this point, it's all loaded up and you can ditch the dump.sql file, as it's no longer needed, and the new version is active:
$ psql --version psql (PostgreSQL) 16.0 (Homebrew)
Not bad at all. 🙂