Database Migrations
external-readyDrizzle migration workflow for schema evolution and safe rollout.
Standard flow
- Update schema definitions in
libs/db/src/schema/**. - Generate a migration.
- Review SQL diff.
- Apply migration in development.
- Commit schema + migration files together.
Commands
bun run db:generate
bun run db:migrateRules
- keep one logical change per migration when possible
- never edit already-applied migration files
- use rollback-forward strategy (new migration to reverse)
- validate on realistic data before production rollout
Validation checklist
- migration applies cleanly in local/staging
- backend typecheck passes
- changed module paths still pass smoke checks