migration-safety-review
Review database migrations before they are applied to prevent data loss, downtime, broken deployments, unsafe constraints, rollback failures, and application-code mismatches. Use when Codex needs to i
SKILL.mdskills/migration-safety-review/SKILL.md
GitHubMigration Safety Review
Use this skill as a safety gate before applying database migrations to real or production-like data.
Core Rule
Do not apply or approve a migration until its data, compatibility, locking, rollback, backup, and application-code risks have been reviewed.
Workflow
- Identify migration scope:
- file name, tables, columns, indexes, constraints, data transformations, models, APIs, frontend behavior, and whether existing data is modified
- Classify risk level:
- low, medium, high, or critical
- Check destructive changes:
- drops, deletes, truncates, irreversible transforms, unsafe renames, data type truncation, cascade deletes, enum removals
- Check backward compatibility:
- old code with new schema, new code with old schema, rolling deploys, background workers, mobile/old clients
- Check existing data compatibility:
- nulls, duplicates, orphan records, invalid enum values, type conversion, invalid dates/numbers
- Check locking and downtime risk.
- Review constraint safety and index strategy.
- Check application code alignment:
- models, validation, services, endpoints, frontend types, jobs, seeds, tests, docs
- Decide if migration order should be split into staged rollout.
- Review rollback plan and backup needs.
- Review staging/dry-run and backfill strategy.
- Pay extra attention to sensitive or financial data.
- Produce a migration safety report with final recommendation.
Read references/migration-review-checklist.md for risk classification, pre-check queries, safe rollout patterns, and the report template.
Non-Negotiable Rules
- Do not approve destructive migrations without warning.
- Do not assume existing data is clean.
- Do not add NOT NULL, UNIQUE, or FOREIGN KEY constraints without checking existing data.
- Do not ignore application-code compatibility.
- Do not ignore mobile or old client compatibility when API fields change.
- Do not ignore rollback planning.
- Recommend backup for medium or higher risk migrations.
- Do not run destructive SQL without explicit approval.
- Do not perform large backfills without batching/resume considerations.
- Do not add cascade delete behavior casually.
Output Contract
When using this skill, provide:
- Migration summary and risk level.
- Tables/fields/indexes/constraints/data changes affected.
- Destructive change check.
- Backward compatibility and existing data compatibility.
- Locking, constraint, and index review.
- Application code alignment review.
- Rollback, backup, and safe deployment recommendation.
- Verification checklist and final recommendation.