data-migrationlisted
Install: claude install-skill RBraga01/a-team
# Data Migration
## The Law
```
EVERY MIGRATION NEEDS A ROLLBACK.
A migration without a rollback plan is a one-way door.
Before you open it, know how to close it.
```
## When to Use
Use this skill before:
- Any `ALTER TABLE` in production
- Any column rename, type change, or removal
- Any large `UPDATE` or `DELETE` (more than 1000 rows)
- Any index creation on a large table
- Any data backfill or transformation script
## The Migration Process
### Step 1: Classify the Migration
| Type | Risk | Strategy |
|------|------|---------|
| Additive (new table, new nullable column) | Low | Single deploy |
| Non-breaking change (add index, add constraint) | Low–Medium | Verify impact first |
| Column rename or type change | High | Multi-phase deploy |
| Column or table removal | High | Multi-phase deploy |
| Large data backfill (>100k rows) | Medium | Batched, off-peak |
| Destructive (DROP TABLE, DELETE) | Critical | Backup + explicit approval |
### Step 2: Write the Migration Plan
Save to `docs/migrations/YYYY-MM-DD-description.md`:
```markdown
# Migration: [Title]
## Summary
[What changes and why]
## Risk Level
[Low / Medium / High / Critical]
## Migration Steps
### UP (apply)
\```sql
-- Step 1: Add new column (nullable — safe, no lock)
ALTER TABLE orders ADD COLUMN discount_amount NUMERIC(10,2);
-- Step 2: Backfill (batched — see script)
-- Run: scripts/migrations/backfill-discount.sql
-- Step 3: Add NOT NULL constraint after backfill
ALTER TABLE orders ALTER COLUMN