home overview tags

Herman verschooten

These things I recently learned, that may be useful to myself and others in the future.

Upgrading Postgresql from 14 to 15 on my iMac

I recently upgraded my Postgresql from 14 to 15 on my M1 iMac Mini, these were the steps I followed.

  • Check if still using the old postgres package name.

    a. Uninstall all installed versions of postgres, take note of the currently used data-directory, eg /usr/local/var/postgres (x86) or
    /opt/homebrew/var/postgres (aarm64)
    b Rename the postgres directory to postgresql@14
    c Install postgresql@14, start it with brew services start postgresql@14, and check if it is working and your data is there.

  • brew install postgresql@15
  • Make v15 the active version, brew link --overwrite postgresql@15, the --overwrite is needed, because we cannot unlink v14, but need the v15 utilities.
  • Stop all postgresql instances
  • Perform the upgrade: pg_upgrade --old-bindir $(brew --prefix postgresql@14)/bin --new-bindir $(brew --prefix postgresql@14)/bin --old-datadir /usr/local/var/postgresql@14/ --new-datadir /usr/local/var/postgresql@15
  • brew services start postgresql@15, and check your data.
  • If all is well, you can now brew uninstall postgresql@14 and then run the generated delete_old_cluster.sh
  • As a last step you can check/remove the log-files generated by the upgrade process. And do the vacuum as mentioned in the upgrade output.