Files
dd0c/products/docker-init-db.sh
Max Mayfield 64213c39e9 Add P1/P2 to docker-compose, mount all 6 migration dirs, add P2 agent Dockerfile
- route-api (3001), route-proxy (8080), route-worker as separate services
- drift SaaS (3002) added
- All 6 product migrations mounted into postgres init
- docker-init-db.sh creates all 6 databases
2026-03-01 06:11:20 +00:00

31 lines
929 B
Bash
Executable File

#!/bin/bash
set -e
# Create per-product databases
for db in dd0c_route dd0c_drift dd0c_alert dd0c_portal dd0c_cost dd0c_run; do
echo "Creating database: $db"
psql -v ON_ERROR_STOP=0 --username "$POSTGRES_USER" --dbname postgres -c "CREATE DATABASE $db;" 2>/dev/null || true
done
# Run migrations for each product
run_migrations() {
local db=$1
local dir=$2
if [ -d "$dir" ]; then
for sql in "$dir"/*.sql; do
[ -f "$sql" ] || continue
echo " $db$(basename $sql)"
psql -v ON_ERROR_STOP=0 --username "$POSTGRES_USER" --dbname "$db" -f "$sql" 2>/dev/null || true
done
fi
}
run_migrations dd0c_route /migrations/01-route
run_migrations dd0c_drift /migrations/02-drift
run_migrations dd0c_alert /migrations/03-alert
run_migrations dd0c_portal /migrations/04-portal
run_migrations dd0c_cost /migrations/05-cost
run_migrations dd0c_run /migrations/06-run
echo "All databases initialized."