Skip to content

Commit be5478c

Browse files
committed
fix: Drop view/Create table locations
1 parent 5c8ee36 commit be5478c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

infrastructure/postgres/setup-analytics.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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

1617
echo "Waiting for PostgreSQL to be ready at ${POSTGRES_HOST}:${POSTGRES_PORT}..."
1718
until 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
3132
DO \$\$
@@ -50,6 +51,7 @@ PGPASSWORD="$POSTGRES_PASSWORD" psql -v ON_ERROR_STOP=1 -h "$POSTGRES_HOST" -p "
5051
5152
CREATE SCHEMA IF NOT EXISTS analytics;
5253
54+
DROP VIEW IF EXISTS analytics.locations;
5355
CREATE TABLE IF NOT EXISTS analytics.locations (
5456
id uuid PRIMARY KEY,
5557
name text NOT NULL,

0 commit comments

Comments
 (0)