Select correct postgresql version in travis build

Viewed 1098

I use TravisCi to build and test a Django based project.

The build fails on db related errors that seems to be linked to the wrong postgres version being used. However, following Travis doc to set Postgres' version does not seem to work as expected.

Here's my .travis.yml file:

language: python
python:
  - "3.6"
addons:
  - postgresql: "9.6"
before_install:
 - cd $TRAVIS_BUILD_DIR/src
install:
 - npm install -g sass
 - make init
before_script:
  - psql --version
  - psql -c 'SELECT version();' -U postgres
  - psql -c "CREATE USER aides WITH CREATEDB PASSWORD 'aides';" -U postgres
script:
 - make checkstyle
 - make test

Here's the build part that's bugging me:

$ psql --version
psql (PostgreSQL) 9.6.6

$ psql -c 'SELECT version();' -U postgres
                                                   version                                                    
--------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.2.24 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4, 64-bit
(1 row)

Unless I'm missing something obvious, it looks like the psql client connects to a server from a different pg version. How do I configure Travis to make sure Postgres server 9.6 is used?

1 Answers
Related