migration-safety-checkerlisted
Install: claude install-skill smicolon/ai-kit
# Migration Safety Checker
Validates Django migrations are production-safe before they cause data loss.
## Activation Triggers
This skill activates when:
- Running `makemigrations`
- Modifying model fields
- Mentioning "migration", "schema", "alter table"
- Adding/removing/renaming fields
- Changing field types
- Creating or modifying migration files
## Safety Requirements
All migrations MUST be:
- ✅ **Reversible** - Can roll back safely
- ✅ **No data loss** - Preserve existing data
- ✅ **Tested** - Run on staging first
- ✅ **Safe for production** - No downtime operations
- ✅ **Documented** - Explain what changes and why
## High-Risk Operations
These operations require special attention:
### 🔴 CRITICAL RISK - Data Loss Possible
1. **Dropping columns** without data migration
2. **Renaming fields** without data migration
3. **Changing field types** (data conversion issues)
4. **Adding non-nullable fields** without default
5. **Removing tables** with data
### 🟡 MEDIUM RISK - Requires Careful Planning
1. **Adding indexes** on large tables (use `CONCURRENTLY`)
2. **Adding unique constraints** (check for duplicates first)
3. **Changing `max_length`** (data truncation risk)
### 🟢 LOW RISK - Generally Safe
1. **Adding nullable fields**
2. **Adding fields with defaults**
3. **Creating new tables**
4. **Adding non-unique indexes**
## Validation Process
### Step 1: Analyze Migration File
When migration is created:
```python
# Generated migration
class Migration(migra