Managing DB Migrations in casedotdev-mono
Quick checklist for committing schema changes with migrations in casedotdev-mono
Database Migration Checklist
Quick reference for schema changes. For full context, see managing-database skill.
Before Committing
# 1. Edit schema (packages/database/src/schema*.ts)
# 2. Generate migration (from repo root - REQUIRED)
bun db:generate
# 3. Review the latest generated migration
cat "$(ls -1 infra/drizzle/*.sql | sort -V | tail -1)"
# 4. Commit BOTH together
git add packages/database/src/schema*.ts infra/drizzle/
git commit -m "CD-XXX: Description (with migration)"
After Merge
Migrations are applied automatically by CI via bun db:migrate. No manual push step is needed.
- Preview deploys run
db:migrateagainst the staging branch - Production deploys run
db:migrateagainst the production branch
Note:
bun db:pushnow errors out intentionally. Usebun db:push:localonly for throwaway local DBs.
Verification
Use Neon MCP to verify the migration was applied:
# Test enum value exists
neon_run_sql({ projectId: "billowing-paper-24157726", sql: "SELECT 'value'::enum_name;" })
# Test column exists
neon_describe_table_schema({ projectId: "billowing-paper-24157726", tableName: "table_name" })
CI Will Block If
- Schema changed but no migration file committed
- Migration file exists but
_journal.jsonnot updated - Schema and migration are out of sync (
bun db:checkfails)
Incident Reference: TG-45 (January 2026)
Multiple PRs merged with schema changes but no migration files. CI caught it at preview → main merge. Had to go back and generate migrations after the fact.
Don't be that engineer. Always run bun db:generate before committing schema changes.