If you’re looking to upgrade Postgres locally in a Rails project, it’s straight-forward-yet-not-simple. It’s not a one-click/one-command operation.
I used the pg_dump
command, along with Homebrew in this example. I have also seen a good post from Christopher Brown and Keita on manually backing up and copying data files using pg_upgrade
. These involve a few more steps that I personally did not need. YMMV, so these are solid alternatives if needed.
- Backup your data.
Runpg_dump
for all databases that you’d like to backup:
$ cd /your/project/root
$ pg_dump your-database-name > choose-a-backup-file-name - Upgrade your Postgres version.
- For Homebrew users:
Verify the version you currently have installed:
$ brew list --versions postgres
or$ psql --version
$ brew update && brew upgrade postgres
- For Homebrew users:
- Verify your Postgres upgrade.
$ brew list --versions postgres
or$ psql --version
- Create your database(s).
rake db:create
- Restore your data.
psql your-database-name < your-backup-file