2026-05-29 23:29:31 +03:30
|
|
|
#!/bin/bash
|
|
|
|
|
# FlatRender V2 — run all schema migrations in order on first postgres init.
|
2026-06-12 21:39:15 +03:30
|
|
|
# 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.
|
2026-05-29 23:29:31 +03:30
|
|
|
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."
|