I’m a bit stuck right now. All I want to do is to use a Postgresql service and to import a sql file into it.
I have postgres:alpine as one of my service. During my test stage I want to use a sql file in my repository and execute the following command : psql -U $POSTGRES_USER --password $POSTGRES_PASSWORD $POSTGRES_DB < ./db/db_create.sql
My variables are also in place, but I can’t find a way to do this (quite simple) manipulation easily. Any clue ?
Are you trying to create a new database in Gitlab’s postgresql?
If so, I was doing something like following to execute a sql statement.
sudo -u gitlab-psql /opt/gitlab/embedded/bin/psql -h /var/opt/gitlab/postgresql/ gitlabhq_production -c “select statement here”
connect:
image: postgres
script:
# official way to provide password to psql: http://www.postgresql.org/docs/9.3/static/libpq-envars.html
- export PGPASSWORD=$POSTGRES_PASSWORD
- psql -h "postgres" -U "$POSTGRES_USER" -d "$POSTGRES_DB" -c "SELECT 'OK' AS status;"