| name | db-migration |
| description | Write and review Flyway database migration scripts with rollback safety for banking schemas |
Database Migration Skill
When to Use
Invoke when creating, reviewing, or troubleshooting database migration scripts.
Flyway Migration Rules
- Versioned: V{NNN}__{description}.sql (e.g., V001__create_accounts.sql)
- Repeatable: R__{description}.sql (for views, functions, seed data)
- Every migration must have a corresponding rollback script
- Test against a copy of production schema before deployment
Migration Template
BEGIN;
COMMIT;
Safety Rules
- Never DROP TABLE in production — use soft delete (add deleted_at column)
- ALTER TABLE on large tables: use CREATE INDEX CONCURRENTLY
- Add columns as NULLABLE first, backfill, then add NOT NULL constraint
- Partition tables > 10M rows by date before they grow
- Always include EXPLAIN ANALYZE for new queries in comments