PostgreSQL 9.2 officially reached its end-of-life (EOL) and as a result it was removed from the build environment as of March 29, 2018.

PostgreSQL 10 is now the new default running on port 5432.

PostgreSQL 10 runs on the default port and the credentials are stored in the PGUSER and PGPASSWORD environment variables. The default databases created for you are development and test.

We install the Ubuntu postgresql-contrib package. It includes the extension modules listed in the PostgreSQL documentation.

You need to activate them with CREATE EXTENSION as explained in the Extension Guide.

Versions

10

The default version of PostgreSQL on Codeship is 10, which runs on the default port of 5432. No additional configuration is required to use version 10.

PostgreSQL 10 includes PostGIS version 2.4.

9.6

PostgreSQL version 9.6 is running on port 5436 and configured (almost) identical to the others. Make sure to specify the correct port in your project configuration if you want to test against this version.

PostgreSQL 9.6 includes PostGIS version 2.3.

For Rails based projects, please add the following command to your Setup Commands to work around the auto-configuration in place.

sed-i"s|5432|5436|""config/database.yml"

9.5

PostgreSQL version 9.5 is running on port 5435 and configured (almost) identical to the others. Make sure to specify the correct port in your project configuration if you want to test against this version.

PostgreSQL 9.5 includes PostGIS version 2.2.

For Rails based projects, please add the following command to your Setup Commands to work around the auto-configuration in place.

sed-i"s|5432|5435|""config/database.yml"

9.4

PostgreSQL version 9.4 is running on port 5434 and configured (almost) identical to the others. Make sure to specify the correct port in your project configuration if you want to test against this version.

PostgreSQL 9.4 includes PostGIS version 2.1.

For Rails based projects, please add the following command to your Setup Commands to work around the auto-configuration in place.

sed-i"s|5432|5434|""config/database.yml"

9.3

PostgreSQL version 9.3 is running on port 5433 and configured (almost) identical to the others. Make sure to specify the correct port in your project configuration if you want to test against this version.

PostgreSQL 9.3 includes PostGIS version 2.1.

For Rails based projects, please add the following command to your Setup Commands to work around the auto-configuration in place.

sed-i"s|5432|5433|""config/database.yml"

pg_dump

You may experience a pg_dump version mismatch with the PostgreSQL version you have configured.

This can be resolved by adding the following command in your Setup Commands before running your migrations:

export PATH=/usr/lib/postgresql/<PG_VERSION>/bin/:$PATH

Run psql commands

You can run any SQL query against the PostgreSQL database. For example to create a new database:

psql -p DATABASE_PORT -c'create database new_db;'

Enable Extensions

You can enable extensions either through your application framework (if supported) or by running commands directly against the database. For example, you would add the following command to your Setup Commands to enable the hstore extension.

PostGIS

PostgreSQL versions 9.3 to 9.4 include PostGIS 2.1, 9.5 includes 2.2, 9.6 includes 2.3 and 10 includes 2.4.

Framework-specific configuration

Ruby on Rails

We replace the values in your config/database.yml file automatically to a configuration matching the PostgreSQL 10 instance.

If your Rails application is stored in a subdirectory or you want to change the database configuration from our default values, you can add the following data to a codeship.database.yml file (or any other filename) and commit that file to your repository.

Notes And Known Issues

Python and earlier Psycopg versions

Earlier versions of Python PostgreSQL client Psycopg may not work with version 10. These older versions used a string-comparison to try and work out the PostgreSQL version number and didn’t account for version 10. To resolve this issue, upgrade psycopg2 to version 2.7 or higher.