Run the database migration workflow after changes to lib/db/schema.ts.
Steps
- •
Generate a new migration:
bashnpm run db:generate
This creates a new file in
drizzle/migrations/. - •
Review the generated migration file to make sure it matches the intended schema changes. Pay attention to:
- •Dropped columns or tables (destructive)
- •Type changes
- •New foreign key constraints
- •
Apply the migration to the local database:
bashnpm run db:migrate
- •
Verify the migration succeeded — if there are errors, review and fix the schema before re-running.
Notes
- •The database must be running (
docker-compose up -d db) before applying migrations. - •Both commands use
cross-env NODE_ENV=developmentinternally — do not set it manually. - •Migration files are checked into git and should be committed alongside schema changes.