Migration Impact Analyzer
The Migration Impact Analyzer scans your codebase before running migrations to detect breaking changes that could cause runtime errors.
Why Use It?
Dropping a table or column is easy—but if your code still references it, you’ll get runtime errors. The analyzer:
- Scans your codebase for QAIL and raw SQL queries
- Detects breaking changes like dropped tables/columns
- Shows exact file locations where code needs updating
- Prevents downtime by catching issues before they hit production
Usage
qail migrate analyze old.qail:new.qail --codebase ./src
Example Output
🔍 Migration Impact Analyzer
Schema: old.qail → new.qail
Codebase: ./src
Scanning codebase...
Found 395 query references
⚠️ BREAKING CHANGES DETECTED
Affected files: 1
┌─ DROP TABLE promotions (6 references) ─────────────────────────┐
│ ❌ src/repository/promotion.rs:89 → INSERT INTO promotions (
│ ❌ src/repository/promotion.rs:264 → SELECT COUNT(*) FROM promotions
│ ❌ src/repository/promotion.rs:288 → UPDATE promotions SET
│ ❌ src/repository/promotion.rs:345 → DELETE FROM promotions WHERE
└────────────────────────────────────────────────────────────────┘
What would you like to do?
1. Run anyway (DANGEROUS - will cause 1 runtime errors)
2. Dry-run first (show SQL, don't execute)
3. Let me fix the code first (exit)
Supported Query Patterns
The analyzer detects:
QAIL Queries
get::users→ SELECT from usersset::users→ UPDATE usersadd::users→ INSERT INTO usersdel::users→ DELETE FROM users
Raw SQL
SELECT ... FROM tableINSERT INTO tableUPDATE table SETDELETE FROM table
Supported File Types
.rs(Rust).ts(TypeScript).js(JavaScript).py(Python)
Breaking Change Types
| Change Type | Severity | Description |
|---|---|---|
DROP TABLE | 🔴 Critical | Table referenced in code will cause runtime errors |
DROP COLUMN | 🔴 Critical | Column queries will fail |
RENAME | 🟡 Warning | Code needs updating to use new name |
TYPE CHANGE | 🟡 Warning | May cause type mismatch errors |
Best Practices
-
Always run before
migrate upqail migrate analyze old.qail:new.qail --codebase ./src qail migrate up old.qail:new.qail $DATABASE_URL -
Add to CI/CD pipeline
- name: Check migration safety run: qail migrate analyze $OLD:$NEW --codebase ./src -
Use with
migrate planfor full previewqail migrate plan old.qail:new.qail # See SQL qail migrate analyze old.qail:new.qail # Check codebase qail migrate up old.qail:new.qail $URL # Apply