Skip to content

Commit

Permalink
Fix setup_db.sh by waiting for pg_isready success return. Fixes dbt-l…
Browse files Browse the repository at this point in the history
  • Loading branch information
rvacaru committed Sep 17, 2021
1 parent 2493c21 commit 0aa174a
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions test/setup_db.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
set -x

env | grep '^PG'

# If you want to run this script for your own postgresql (run with
Expand Down Expand Up @@ -30,16 +29,9 @@ if [[ -n $CIRCLECI ]]; then
connect_circle
fi

createdb dbt
psql -c "CREATE ROLE root WITH PASSWORD 'password';"
psql -c "ALTER ROLE root WITH LOGIN;"
psql -c "GRANT CREATE, CONNECT ON DATABASE dbt TO root WITH GRANT OPTION;"

psql -c "CREATE ROLE noaccess WITH PASSWORD 'password' NOSUPERUSER;"
psql -c "ALTER ROLE noaccess WITH LOGIN;"
psql -c "GRANT CONNECT ON DATABASE dbt TO noaccess;"

psql -c 'CREATE DATABASE "dbtMixedCase";'
psql -c 'GRANT CREATE, CONNECT ON DATABASE "dbtMixedCase" TO root WITH GRANT OPTION;'
until pg_isready -h ${PGHOST} -p ${PGPORT} -U ${PGUSER}; do
echo "Waiting for postgres to be ready..."
sleep 2;
done;

set +x

0 comments on commit 0aa174a

Please sign in to comment.