File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,9 @@ set -euo pipefail
1010: " ${ANALYTICS_POSTGRES_USER:? Must set ANALYTICS_POSTGRES_USER} "
1111: " ${POSTGRES_PASSWORD:? Must set POSTGRES_PASSWORD} "
1212: " ${KEEP_ALIVE_SECONDS:= 0} " # Prevent Swarm from marking this task as failed due to early exit
13+ : " ${TARGET_DB:= events} "
1314
14- TARGET_DB=" events "
15+ TARGET_DB=${TARGET_DB // - / _}
1516
1617echo " Waiting for PostgreSQL to be ready at ${POSTGRES_HOST} :${POSTGRES_PORT} ..."
1718until PGPASSWORD=" $POSTGRES_PASSWORD " psql -h " $POSTGRES_HOST " -p " $POSTGRES_PORT " \
@@ -25,7 +26,7 @@ create_or_update_role() {
2526 local role=$1
2627 local password=$2
2728 local db=$3
28-
29+ echo " Creating or updating role ' $role ' with access to database ' $db '... "
2930 PGPASSWORD=" $POSTGRES_PASSWORD " psql -v ON_ERROR_STOP=1 -h " $POSTGRES_HOST " -p " $POSTGRES_PORT " \
3031 -U " $POSTGRES_USER " -d postgres << EOSQL
3132DO \$\$
@@ -50,6 +51,7 @@ PGPASSWORD="$POSTGRES_PASSWORD" psql -v ON_ERROR_STOP=1 -h "$POSTGRES_HOST" -p "
5051
5152CREATE SCHEMA IF NOT EXISTS analytics;
5253
54+ DROP VIEW IF EXISTS analytics.locations;
5355CREATE TABLE IF NOT EXISTS analytics.locations (
5456 id uuid PRIMARY KEY,
5557 name text NOT NULL,
You can’t perform that action at this time.
0 commit comments