mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 16:27:37 +01:00
The `migrate` script aliased `drizzle-kit push`, training the habit of diff-applying unreviewed schema to whatever DATABASE_URL points at — prod, if misconfigured. Rename it to `db:push` so the name no longer reads as the normal workflow, document it as local/scratch-only, and point every call-site at the generate → review → forward-apply loop instead. No `db:migrate` alias added: there is no local forward-only applier (the deploy owns forward-apply via apply-schema.sh), so a hollow alias would just be a new landmine. Call-sites updated: README, check-schema-drift, deploy-host, deploy-local, postgres-portability. Implements docs/infrastructure/migration-strategy.md §3; the optional CI guard is deferred there (it collides with the raw-SQL migration path until the two paths are unified). Co-authored-by: test <test@test> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Bootstrap Postgres host on a fresh Hetzner Ubuntu VM.
|
|
#
|
|
# Usage (on the VM):
|
|
# curl -fsSL https://raw.githubusercontent.com/.../deploy-host.sh | bash
|
|
# Or copy infra/postgres-host/ to the VM and run:
|
|
# cd infra/postgres-host && cp .env.example .env && $EDITOR .env && ./deploy-host.sh
|
|
#
|
|
# After deploy:
|
|
# DATABASE_URL=postgresql://studio:PASS@HOST:5432/cockpit
|
|
# DATABASE_POOL_URL=postgresql://studio:PASS@HOST:6432/cockpit
|
|
# The app connects over localhost on the same box, so keep :5432/:6432 bound
|
|
# to localhost only. Open the firewall (or use a tunnel) only for remote access.
|
|
|
|
set -euo pipefail
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
HOST_DIR="$DIR/../../infra/postgres-host"
|
|
|
|
if [ ! -f "$HOST_DIR/.env" ]; then
|
|
echo "Create $HOST_DIR/.env from .env.example first." >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v docker >/dev/null 2>&1; then
|
|
echo "Installing Docker..."
|
|
curl -fsSL https://get.docker.com | sh
|
|
sudo usermod -aG docker "$USER" 2>/dev/null || true
|
|
fi
|
|
|
|
chmod +x "$HOST_DIR/init/"*.sh 2>/dev/null || true
|
|
docker compose -f "$HOST_DIR/docker-compose.yml" --env-file "$HOST_DIR/.env" up -d
|
|
|
|
echo ""
|
|
echo "Postgres host is up (localhost-only ports bound — open firewall or tunnel for remote access)."
|
|
echo "Next: set DATABASE_URL in the app .env → push schema with npm run db:push"
|