20 lines
581 B
Bash
20 lines
581 B
Bash
|
|
#!/bin/bash
|
||
|
|
# FlatRender V2 — run all schema migrations in order on first postgres init.
|
||
|
|
# Mounted at: /docker-entrypoint-initdb.d/00-init.sh
|
||
|
|
# Migrations dir mounted at: /migrations (read-only)
|
||
|
|
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."
|