Skip to content

Commit

Permalink
Fix databases creation script
Browse files Browse the repository at this point in the history
  • Loading branch information
noliveleger committed May 30, 2024
1 parent cea9364 commit 5695a37
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions scripts/wait_for_postgres.bash
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ done

source /etc/profile

echo "Postgres service running; ensuring ${POSTGRES_DB} database exists and has PostGIS extensions..."
psql -d postgres -h "${POSTGRES_HOST}" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" <<EOF
CREATE DATABASE "$POSTGRES_DB" OWNER "$POSTGRES_USER";
\c "$POSTGRES_DB"
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
EOF
echo "Postgres database ${POSTGRES_DB} ready for use!"

DATABASES_LIST="${KPI_POSTGRES_DB} ${KC_POSTGRES_DB}"

for POSTGRES_DB in "${DATABASES_LIST}"; do
echo "Postgres service running; ensuring ${POSTGRES_DB} database exists and has PostGIS extensions..."
psql -d postgres -h "${POSTGRES_HOST}" -p "${POSTGRES_PORT}" -U "${POSTGRES_USER}" <<EOF
CREATE DATABASE "$POSTGRES_DB" OWNER "$POSTGRES_USER";
\c "$POSTGRES_DB"
CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;
EOF
echo "Postgres database ${POSTGRES_DB} ready for use!"
done

0 comments on commit 5695a37

Please sign in to comment.