analyze_migration
Analyze SQL migrations for lock risks, data loss, and unsafe patterns before execution. Detects blocking locks, destructive operations, and cascade hazards.
Instructions
Analyze a SQL migration file for lock risks, data loss potential, and unsafe patterns. Detects: ACCESS EXCLUSIVE locks (DROP TABLE, ADD COLUMN NOT NULL, type changes, CREATE INDEX without CONCURRENTLY), data loss operations (TRUNCATE, DELETE without WHERE, UPDATE without WHERE, DROP COLUMN), and cascade risks. Supports Flyway versioned (V__*.sql) and repeatable (R__*.sql) migrations, as well as plain SQL files.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL content of the migration file | |
| filename | Yes | Migration filename (e.g., V2__add_user_email.sql) |