Skip to content

Instantly share code, notes, and snippets.

@landovsky
Last active March 21, 2023 11:08
Show Gist options
  • Save landovsky/ae0aa997a30fadfb7878de8b35cd141f to your computer and use it in GitHub Desktop.
Save landovsky/ae0aa997a30fadfb7878de8b35cd141f to your computer and use it in GitHub Desktop.
Upgrade postgresql 14 to 15 on Macos using brew and pg_upgrade

Stop old postgres

brew services stop postgresql@14

Install new postgres and make sure it is stopped

brew install postgresql@15

brew services stop postgresql@15

Perform upgrade

  • optionally add --check argument to test upgradability between versions
  • /opt/homebrew/var/postgresql@14 is where old data lives. If you can't determine the data dir, fire up old postgres again and run SHOW data_directory;.
  • /opt/homebrew/var/postgresql@15 is where new data lives
  • see pg_upgrade docs for more info

/opt/homebrew/Cellar/postgresql@15/15.1/bin/pg_upgrade -d /opt/homebrew/var/postgresql@14 -b /opt/homebrew/Cellar/postgresql@14/14.6/bin -D /opt/homebrew/var/postgresql@15

Unlink old version

brew unlink postgresql@14

Link new version and start

brew link postgresql@15 brew services start postgresql@15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment