docs(db): migration safety checklist and deploy workflow pitfalls from the 17 September outage

Merged
KI
2mo ago
+192-9

Summary

Records what the 17 September 2026 API outage and its follow-through taught us, in the places an engineer or agent reads before repeating the mistake. Documentation only, no behaviour changes.

Post mortem: https://app.superset.sh/page/post-mortem-api-outage-17-september-2026-bwc63i
Follow-through PRs: #7671, #7672, #7675

Changes

  • .agents/skills/db-migrations/SKILL.md: reworked into generate steps, a safety checklist, and the rules behind it. Closes the P1 action item "add a migration safety checklist to the db-migrations skill".
    • drizzle applies every pending migration in one transaction, so splitting files gives no lock isolation
    • no column type change on a large, busy table; the safe shapes instead
    • take locks child first, then parents; the one legitimate reason to hand-order a generated file (still needs explicit user confirmation, plus a SQL comment)
    • which tables are hot, with the measured numbers
    • a read-only production size query, and sizes as of 2026-09-19
    • rehearsing on a Neon branch of production under pgbench load, not only on a quiet copy
    • what the deploy-database job enforces (concurrency group, lock and statement timeouts, 8 retries on lock races only, verify-migrations-applied.ts)
    • a reused preview Neon branch makes the PR database check a no-op
    • moving where data is read from means moving the data in the same release (#7317)
  • docs/deploy-workflows.md (new): run: has no pipefail unless shell: bash is set, production secrets exist only as GitHub environment secrets, the Deployments page rows are cosmetic, wait about 20 seconds after gh workflow enable. No existing doc fit: docs/environment-variables.md is a five-step how-to for one task, docs/agent-tooling.md and scripts/release/README.md are unrelated.
  • AGENTS.md: "Further reading" pointer to the new doc; the Database section now mentions the checklist.
  • docs/environment-variables.md: one cross-link from the environment: scoping paragraph.

Verification

  • bun run lint: pass
  • bun run lint:prose (apps/marketing): 0 errors, 0 warnings
  • vale --minAlertLevel=warning directly on the skill and the new doc: clean. docs/environment-variables.md has pre-existing em dashes outside the CI lint scope; left alone here.
  • Checked against the repo: PgDialect.migrate in drizzle-orm 0.45.2, the deploy-database job, verify-migrations-applied.ts, backfill-connections.yml, the branch_name: github.head_ref in deploy-preview.yml, the hand-order comment in migration 0119. Production measurements are as verified on 2026-09-19.

Summary by cubic

Records what the 17 September 2026 API outage and its follow-through taught us about database migrations and deploy workflows. Documentation only; no behavior changes.

  • Reworks .agents/skills/db-migrations/SKILL.md into generate steps and a production safety checklist, closing the P1 post-mortem action item.
  • Adds docs/deploy-workflows.md covering piped run: steps without pipefail, production secrets existing only as GitHub environment secrets, cosmetic Deployments page rows, and waiting about 20 seconds after gh workflow enable.
  • Updates AGENTS.md and docs/environment-variables.md to point to the new guidance.

Summary by CodeRabbit

  • Documentation
    • Expanded database migration guidance with production safety checklists, lock and backfill considerations, load rehearsals, deployment timeout handling, verification steps, and preview-branch reset requirements.
    • Added deployment workflow guidance covering reliable failure detection, production secret access, workflow environments, and safe dispatch timing.
    • Clarified environment-variable behavior for jobs and one-off scripts requiring production secrets.
    • Documented incident-specific migration and deployment lessons for future operational reference.