Upgrade PostgreSQL from 9.4/9.5 to 9.6
After upgrading everything in Homebrew, I discovered that my PostgreSQL no longer loaded, due to the database files being an older version than the PostgreSQL software. These are the steps I followed to upgrade all databases, and get up and running again.
1: Make sure PostgreSQL is not running before starting the upgrade process.
2: Make a new PostgreSQL 9.6 database where your old data will be migrated to.
% initdb /usr/local/var/postgres_new -E utf8
3: Upgrade databases to 9.6 by using pg_upgrade
tool. To find the version number of the
old binaries, you simply ls /usr/local/Cellar/postgresql
.
% pg_upgrade \
-b /usr/local/Cellar/postgresql/9.5.4_1/bin/ \
-B /usr/local/Cellar/postgresql/9.6.1/bin/ \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres_new
Change the version numbers needed for your setup, usage of the pg_upgrade tool is as simple as:
pg_upgrade -b oldbindir -B newbindir -d olddatadir -D newdatadir
4: Move your new database to the PostgreSQL default location:
% mv /usr/local/var/postgres /usr/local/var/postgres9.5
% mv /usr/local/var/postgres_new /usr/local/var/postgres
5: That’s it :)
Recent Posts
Extend ActiveStorage::Blob with callbacks
ActiveStorage is currently missing both validations and callbacks, but you can easily extend it with the callbacks you need.
Writing a custom analyzer for ActiveStorage
Writing custom analyzers for your ActiveStorage blogs is not well documented, but quite easy. This is how I implemented a simple EDI file analyzer for my neverending hobby project.
Manjaro/Arch: transfer packages to another computer
How to make a backup of all installed packages on a Arch/Manjaro distro, and install them on a different machine.