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!