Initial commit
This commit is contained in:
16
scripts/init-db.sh
Executable file
16
scripts/init-db.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
PG_BIN="${PG_BIN:-/opt/homebrew/opt/postgresql@17/bin}"
|
||||
|
||||
if ! "$PG_BIN/psql" -d postgres -tAc "SELECT 1 FROM pg_roles WHERE rolname = 'queue'" | grep -q 1; then
|
||||
"$PG_BIN/psql" -d postgres -v ON_ERROR_STOP=1 -c "CREATE ROLE queue LOGIN PASSWORD 'queue'"
|
||||
fi
|
||||
|
||||
if ! "$PG_BIN/psql" -d postgres -tAc "SELECT 1 FROM pg_database WHERE datname = 'queue'" | grep -q 1; then
|
||||
"$PG_BIN/createdb" -O queue queue
|
||||
fi
|
||||
|
||||
"$PG_BIN/psql" "postgres://queue:queue@localhost:5432/queue?sslmode=disable" -v ON_ERROR_STOP=1 -c "SELECT 1" >/dev/null
|
||||
echo "PostgreSQL development database is ready."
|
||||
|
||||
Reference in New Issue
Block a user