Artboard
Classic Docs
Docs Navigation

PostgreSQL

Semaphore supports 2 versions of PostgreSQL:

  • 9.6
  • 10.0

The default version is 9.6, and it's running on port of 5432.

Versions can be changed by adding change-pg-version <version> to your setup commands:

change-pg-version 10

This will shut down the currently active version, start version 10, and export PGCLUSTER=10. After this, the whole PostgreSQL toolchain will be switched to version 10, and port 5432 will be served by the newly selected version as well.

Note that adding this command to a script currently isn't supported.

Credentials for using PostgreSQL are available in environment variables listed below:

Name Value
DATABASE_POSTGRESQL_USERNAME runner
DATABASE_POSTGRESQL_PASSWORD semaphoredb

If your application doesn't create its own database as part of the start-up process, you can create a PostgreSQL database manually. Adding the following command to your build commands will create a PostgreSQL database:

createdb test_db -U $DATABASE_POSTGRESQL_USERNAME

Note that the createdb command doesn't require password, since PostgreSQL doesn't require password for accessing a database that belongs to the PostgreSQL user that has the same name as host operating system user, by default.

# Executing Postgres commands

Add a build command which looks something like:

psql -c "some command" -d $DATABASE_NAME_TEST -P pager

List of all packages and versions is available on the supported application stack page.

# PostgreSQL hstore schema extension

In case your database setup enables the hstore extension in structure.sql, but it does not work as expected, please check if you have something similar to following in your structure.sql file:

CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;

The hstore extension is enabled by default, which prevents your structure.sql to re-create it with the public schema, due to:

CREATE EXTENSION IF NOT EXISTS

A simplified solution would be to drop the existing extension, as the first step in the setup, and let structure.sql do its thing afterwards.

psql -c 'DROP EXTENSION hstore' -d template1

# Extensions

Semaphore Docs are open source — Edit on GitHub

Newsletter

Occasional lightweight product and blog updates. Unsubscribe at any time.

2009-2019 © Rendered Text. All rights reserved. Terms of Service, Privacy policy, Security.