Files
memind/scripts/ensure-goose-v149-local-db.sh
T
john 716ef407fe feat(goose): add local v1.49 canary routing, smoke gates, and migration docs
Wire Portal and TKMind proxy to loopback Goose v1.49 via canary env blocks,
with verification scripts, Phase 2/3 evidence baselines, and rollback runbooks
so local upgrade stays isolated from stable 1.41 and production.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-08 21:10:20 +08:00

41 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# Create isolated PostgreSQL database for Goose v1.49 local upgrade testing.
# Refuses production hosts (103/105/RDS).
set -euo pipefail
PG_HOST="${GOOSE_V149_PG_HOST:-127.0.0.1}"
PG_PORT="${GOOSE_V149_PG_PORT:-5432}"
DB_NAME="${GOOSE_V149_SESSION_DB:-goose_sessions_v149_dev}"
PG_USER="${GOOSE_V149_PG_USER:-${USER:-john}}"
fail() {
echo "[goose-v149-db] FAIL: $*" >&2
exit 1
}
case "${PG_HOST}" in
127.0.0.1|localhost|::1) ;;
58.38.22.103|120.26.184.105|*rds.aliyuncs.com*|*tkmind.cn*)
fail "refusing production or remote host: ${PG_HOST}"
;;
*)
fail "unexpected PG host (only loopback allowed): ${PG_HOST}"
;;
esac
export PATH="/opt/homebrew/opt/postgresql@17/bin:${PATH:-/usr/bin:/bin}"
if ! pg_isready -h "${PG_HOST}" -p "${PG_PORT}" -q 2>/dev/null; then
bash "$(cd "$(dirname "$0")/.." && pwd)/scripts/ensure-goose-session-postgres.sh"
fi
if psql -h "${PG_HOST}" -p "${PG_PORT}" -U "${PG_USER}" -d postgres -tAc \
"SELECT 1 FROM pg_database WHERE datname='${DB_NAME}'" | grep -q 1; then
echo "[goose-v149-db] database already exists: ${DB_NAME}"
else
createdb -h "${PG_HOST}" -p "${PG_PORT}" -U "${PG_USER}" "${DB_NAME}"
echo "[goose-v149-db] created database: ${DB_NAME}"
fi
echo "[goose-v149-db] GOOSE_SESSION_DB_URL=postgresql://${PG_USER}@${PG_HOST}:${PG_PORT}/${DB_NAME}"