db-migrations
Installation
SKILL.md
DB migrations
A migration that is correct on a quiet database can still take production down. On 17 September
2026 migration 0119 rewrote ingest.webhook_events (about 540 GB with indexes) while holding
ACCESS EXCLUSIVE on the auth tables, and took the API down. Generate the migration with the steps
below, then clear the safety checklist before opening the PR.
Generate
- Spin up a new Neon branch and point the root
.envfiles at it.NEON_ORG_IDandNEON_PROJECT_IDare in.env; the Neonlist_projectstool needsorg_idpassed in. - Change the schema in
packages/db/src/schema/. - Run
bunx drizzle-kit generate --name="<sample_name_snake_case>"frompackages/db. - Apply it to your dev branch only. Never apply against a shared or production database; those go through the deploy flow described under "What the production deploy does".
Never hand-edit packages/db/drizzle/ (.sql files, meta/_journal.json, snapshots) without
explicit user confirmation. Change the schema and let drizzle-kit generate write the files. The
one legitimate reason to ask for that confirmation is statement order (rule 3).