| set -euo pipefail | |
| DBOPS=${DBOPS_ROOT:-/data/adaptai/platform/dbops} | |
| PGBIN=$DBOPS/binaries/postgres/bin | |
| HOST=127.0.0.1 | |
| PORT=${PG_PORT:-17532} | |
| DB=${PG_DB:-appdb} | |
| USER=${PG_USER:-app} | |
| echo "[psql_bootstrap] creating roles/db if needed" | |
| "$PGBIN/psql" -U postgres -h "$HOST" -p "$PORT" -d postgres -v ON_ERROR_STOP=1 -c "CREATE USER \"$USER\";" 2>/dev/null || true | |
| "$PGBIN/psql" -U postgres -h "$HOST" -p "$PORT" -d postgres -v ON_ERROR_STOP=1 -c "CREATE DATABASE \"$DB\" OWNER \"$USER\";" 2>/dev/null || true | |
| "$PGBIN/psql" -U postgres -h "$HOST" -p "$PORT" -d "$DB" -v ON_ERROR_STOP=1 -c "CREATE EXTENSION IF NOT EXISTS vector;" || true | |
| echo "[psql_bootstrap] done" | |