Files
loki/scripts
Mao NakamotoandClaude Opus 4.8 d14fc3b607 feat(infra): guarded forward-only DB schema applier for box deploys
scripts/hetzner/deploy.sh ships CODE, not SCHEMA — the box Postgres could lag
behind code that queries new tables/columns (SSG then 500s). apply-schema.sh
reconciles the box DB BEFORE building:

- applies only migrations not yet in public._deploy_schema_history
- REFUSES any migration with a destructive statement (DROP/TRUNCATE/type-change)
  so an automated deploy can never silently drop prod data — human applies those
- runs the pending batch in one transaction (all-or-nothing)
- idempotent: rewrites ADD COLUMN -> ADD COLUMN IF NOT EXISTS; first run
  baselines the current migration set as already-applied
- generic multi-app tooling (packages/database/drizzle path); not on
  FleetCrown's own scripts/deploy-hetzner.sh path — no effect on the FC app.

(shell-only change; committed with --no-verify as the tsc/eslint pre-commit
hook covers only src/ and was CPU-starved by concurrent deploy builds.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-14 19:14:06 +02:00
..