Files
flatrender/deploy/postgres-initdb/00-init.sh
T

21 lines
723 B
Bash
Raw Normal View History

#!/bin/bash
# FlatRender V2 — run all schema migrations in order on first postgres init.
# This whole directory is mounted at /docker-entrypoint-initdb.d (a DIRECTORY mount
# is robust; a single-file bind mount can leave a stale empty dir in a reused CI
# workspace → "Is a directory"). Migrations dir mounted read-only at /migrations.
set -e
MIGRATIONS_DIR="/migrations"
echo "==> FlatRender: running schema migrations from $MIGRATIONS_DIR"
for f in $(ls "$MIGRATIONS_DIR"/*.sql | sort); do
echo " Applying: $(basename "$f")"
psql -v ON_ERROR_STOP=1 \
--username "$POSTGRES_USER" \
--dbname "$POSTGRES_DB" \
--file "$f"
done
echo "==> FlatRender: all migrations applied."