#!/usr/bin/env bash
# Starts the existing Bousla dev PostgreSQL cluster (port 5433) if it is not running.
set -euo pipefail
PGBIN="/c/Program Files/PostgreSQL/18/bin"
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
export PGHOST=127.0.0.1 PGPORT=5433 PGUSER=postgres
if "$PGBIN/pg_isready.exe" -q; then
  echo "Dev cluster already running on port 5433."
  exit 0
fi
"$PGBIN/pg_ctl.exe" -D "$ROOT/.pgdata" -l "$ROOT/pglogs/postgresql.log" \
  -o "-p 5433 -c listen_addresses=127.0.0.1" start
