Postgres 11 with Postgis

Hi. I’m trying to install Postgres 11 with Postgis using the instructions from https://docs.travis-ci.com/user/database-setup/#using-a-different-postgresql-version.

Relevant snippet from my .travis.yml file:

addons:
  postgresql: 11
  apt:
    packages:
      - postgresql-11-postgis-2.5
      - postgresql-client-11

services:
  - postgresql

env:
  global:
    - PGPORT=5433
    - PGUSER=travis

But I keep getting this error:

$ psql -U postgres -c "CREATE EXTENSION postgis"
psql: FATAL:  Peer authentication failed for user "postgres"
The command "psql -U postgres -c "CREATE EXTENSION postgis"" failed and exited with 2 during .

Any help is much appreciated.

Thanks

Hey,

This custom [0] .travis.yml file should be helpful for what you need.

Thanks,
Mustafa
Travis CI Staff

[0] Travis CI - Test and Deploy with Confidence

@mustafaergul Thanks for reaching out and sorry about the late reply. I got distracted.

So I tried the custom .travis.yml that you linked to but I get an auth error now:

could not connect to postgres: error: password authentication failed for user “travis”

A Postgres restart fixed it, for those interested.
So my working before_install looks like this:

before_install:
  - sudo sed -i -e "/local.*peer/s/postgres/all/" -e "s/peer\|md5/trust/g" /etc/postgresql/*/main/pg_hba.conf
  - postgres --version
  - sudo pg_ctlcluster 11 main restart