pretendo-docker/scripts/run-in-container/postgres-init.sh
Matthew Lopez 6290a7f269
Switch to running the Postgres init script manually during setup
This should hopefully fix the issue where some people run the setup script but no Postgres databases get created.
2024-07-13 19:54:25 -04:00

13 lines
343 B
Bash

#!/bin/sh
set -eu
databases="friends super_mario_maker"
for database in $databases; do
if [ "$(psql -At -U "$POSTGRES_USER" -c "SELECT 1 FROM pg_database WHERE datname='$database'")" = '' ]; then
echo "Creating database: $database"
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -c "CREATE DATABASE $database;"
fi
done