Check a Postgres migration for lock and safety risks
analyze_migrationCheck PostgreSQL migration SQL before running or committing to flag table locks, table rewrites, and code-breaking statements, with a safer rewrite for each finding.
Instructions
Analyzes Postgres migration SQL and reports statements that lock tables, rewrite them, or break running code (CREATE INDEX without CONCURRENTLY, volatile defaults, SET NOT NULL, foreign keys without NOT VALID, renames, missing lock_timeout, ...). Call this before running or committing any migration. Each finding includes a safer rewrite.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sql": "<sql>"
},
"name": "analyze_migration"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The full migration SQL. | |
| postgres_version | No | Target Postgres major version (default 16). | |
| assume_transaction | No | True if the migration tool wraps each file in a transaction (Rails, Django, Prisma, Knex do by default). |