Boone Putney bio photo

Boone Putney

Software Development
Random Musings
Austin, Texas

HumanPlanet Soleer

Email LinkedIn Github

PostgreSQL 9.4 includes many great features. The main one we’ve been leveraging is the jsonb field type. Currently the latest LTS version of Ubuntu (14.04), includes postgresql-9.3. Here is how to upgrade to PostgreSQL 9.4, including how to upgrade existing database clusters.

Install the package

Add PostgreSQL 9.4 repository

$ sudo echo 'deb trusty-pgdg main' > /etc/apt/sources.list.d/pgdg.list

Import repository signing key, and update the package lists

$ wget --quiet -O - | \
  sudo apt-key add -
$ sudo apt-get update

Install PostgreSQL 9.4 and pgAdmin III

$ sudo apt-get install postgresql-9.4 pgadmin3

Confirm Version

$ psql --version

Check version of existing database

SELECT version();

Upgrade existing PostgreSQL 9.3 database cluster(s)

Check current clusters

$ pg_lsclusters

Stop PostgreSQL 9.4 cluster & drop it

$ sudo pg_dropcluster 9.4 main --stop

Upgrade PostgreSQL 9.3 cluster to 9.4

$ sudo pg_upgradecluster 9.3 main

Drop PostgreSQL 9.3 cluster

$ sudo pg_dropcluster 9.3 main

Confirm only 9.4 cluster remains

$ pg_lsclusters

Credits for the above: