rails-migration-safety
Installation
SKILL.md
Rails Migration Safety
Use this skill when schema changes must be safe in real environments.
Core principle: Prefer phased rollouts over one-shot migrations on large or busy tables.
Quick Reference
| Operation | Safe Pattern |
|---|---|
| Add column | Nullable first, backfill later, enforce NOT NULL last |
| Add index (large table) | algorithm: :concurrent (PG) / :inplace (MySQL) |
| Backfill data | Batch job, not inside migration transaction |
| Rename column | Add new, copy data, migrate callers, drop old |
| Add NOT NULL | After backfill confirms all rows have values |
| Add foreign key | After cleaning orphaned records |
| Remove column | Remove code references first, then drop column |
HARD-GATE
Related skills