Skip to content

Instantly share code, notes, and snippets.

@eminkel
Created September 28, 2025 23:27
Show Gist options
  • Save eminkel/305b52e5986580faecc0e0527c010c10 to your computer and use it in GitHub Desktop.
Save eminkel/305b52e5986580faecc0e0527c010c10 to your computer and use it in GitHub Desktop.
pg-18-homebrew

Step 1:

brew install postgresql@18

Step 2:

Disable all postgresql running services:

brew services stop postgresql@OLD_VERSION

Note: you'll likely have at least 2 version installed at this current point.

Step 3:

Ensure checksum is enabled on your previous installed postgresql version, I believe postgresql@18 enables by default. So, it's a requirement to run the upgrade tool.

pg_checksums --enable -D /opt/homebrew/var/postgresql@OLD_VERSION

Step 3a:

If your cluster is still running, try to force stop:

pg_ctl stop -m fast

Step 4:

Run the pg_upgrade command with the check flag:

$(brew --prefix)/opt/postgresql@18/bin/pg_upgrade \
  -b $(brew --prefix)/opt/postgresql@OLD_VERSION/bin \
  -B $(brew --prefix)/opt/postgresql@18/bin \
  -d $(brew --prefix)/var/postgresql@OLD_VERSION \
  -D $(brew --prefix)/var/postgresql@18 \
  --check

Once this completes and everything is okay, remove the check flag and run fully.

Step 5:

Confirm all your databases transferred over, connect via your means of connection and confirm version 18 is showing.

Step 6:

Run the delete_old_cluster.sh file that was created in the directory you're in. This will remove the old version of postgresql.

Step 7:

Update your linked version of psql.

brew unlink postgresql@OLD_VERSION brew link postgres@18

Test that your command line psql is version 18:

psql --version

Yay! You did it!

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