Test a Database Migration
Workflow for verifying database migrations work correctly
CLAUDE.md
When testing a database migration:
- Run the up migration on an empty database. Verify the schema is created correctly.
- Run the up migration on a database with existing data. Verify data is preserved and transformed correctly.
- Run the down migration. Verify the schema reverts to its previous state.
- Run up, then down, then up again. Verify idempotency — the final state should match the first up.
- Test with edge cases: null values in columns being modified, empty tables, tables with millions of rows (use a representative subset).
- Verify application code works against both the old and new schema during the migration window.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.