| name | migration |
| description | Safe workflow for creating and applying database schema changes. Use when the user needs to modify the database schema. |
Skill: Create Database Migration
Trigger
When the user needs to modify the database schema.
Steps
Step 1: Plan the Change
Step 2: Create Migration File
Step 3: Safety Checks
Step 4: Data Migration
If needed:
Step 5: Test Migration
Step 6: Update Code
If a step fails
| Step | Failure | Recovery |
|---|
| Step 2 | Syntax error in migration | Fix SQL; re-run |
| Step 4 | Data migration fails mid-run | Script should be idempotent; fix and re-run; if partial data, document manual cleanup |
| Step 5 | Test migration fails | Run DOWN migration to revert; fix UP migration; retest |
| Step 5 | Rollback test fails | Fix DOWN migration; ensure DOWN fully reverts UP before retrying |
Never apply migrations to production without testing UP and DOWN in a non-prod environment first.
Completion
Migration created, tested, and code updated. Ready for review.