File size: 684 Bytes
503b0e9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/env bash
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"