migratoor
Database migration safety checker MCP server that analyzes SQL for dangerous patterns and provides safe alternatives.
README
migratoor
Database migration safety checker MCP server. Catch dangerous migrations before they hit production.
Problem
Developers write migrations, deploy, and accidentally lock production tables for minutes. Or drop a column that running code still references. Or create an index that blocks all writes. These cause real outages.
migratoor checks your SQL migrations against 14 proven safety rules from Squawk and strong_migrations, explains why each pattern is dangerous, and suggests the safe alternative — all as MCP tools in your AI editor.
Quick Start
As MCP Server
Works with any MCP-compatible client — Claude Code, Claude Desktop, Cursor, Windsurf, VS Code (Copilot), Continue.dev, Zed, Cline, and more.
{
"mcpServers": {
"migratoor": {
"command": "npx",
"args": ["-y", "@mrzadexinho/migratoor"]
}
}
}
As Library
import { analyzeMigration, formatReport } from '@mrzadexinho/migratoor';
const result = analyzeMigration(`
ALTER TABLE users ADD COLUMN email TEXT NOT NULL;
CREATE INDEX idx_email ON users (email);
`);
console.log(formatReport(result));
// [CRITICAL] Adding NOT NULL column without default blocks reads/writes
// [CRITICAL] Creating index without CONCURRENTLY blocks all writes
// Safe alternatives provided for each finding
MCP Tools
| Tool | Description |
|---|---|
check_migration |
Analyze SQL (file path or inline) for safety issues with risk levels and safe alternatives |
list_rules |
List all 14 migration safety rules with severity and description |
explain_rule |
Deep dive on a specific rule — why it's dangerous, what lock it takes, safe pattern |
Rules
Critical (blocks reads/writes, causes outages)
| Rule | What it catches |
|---|---|
add-column-not-null-without-default |
Adding NOT NULL column without default rewrites entire table under ACCESS EXCLUSIVE lock |
create-index-not-concurrently |
CREATE INDEX blocks all writes during index build |
change-column-type |
Changing column type rewrites entire table under ACCESS EXCLUSIVE lock |
add-foreign-key-without-validation |
Adding FK validates all rows, blocking writes |
set-not-null-on-existing-column |
SET NOT NULL scans all rows under exclusive lock |
Warning (breaks running code, data risk)
| Rule | What it catches |
|---|---|
drop-column |
Dropping column breaks cached ORM attributes and running code |
drop-table |
Data loss risk, breaks dependent views/functions |
rename-column |
Running code referencing old name fails immediately |
rename-table |
Same as rename column with wider blast radius |
add-unique-constraint |
ACCESS EXCLUSIVE lock during index build |
Info (best practices)
| Rule | What it catches |
|---|---|
prefer-text-over-varchar |
VARCHAR(N) has no performance benefit over TEXT in PostgreSQL |
prefer-jsonb-over-json |
JSON lacks equality operators and indexing, use JSONB |
multiple-ddl-statements |
Multiple DDL in one migration makes rollback harder |
data-in-ddl-migration |
Mixing DML with DDL risks inconsistent state on failure |
Every critical and warning finding includes the safe alternative SQL — not just "this is wrong" but "here's exactly how to fix it."
Example Output
# Migration Safety Check
**3 statement(s) analyzed, 2 issue(s) found:**
- 2 critical
**This migration is NOT safe to run in production.**
## Critical
[CRITICAL] **Adding NOT NULL column without default blocks reads/writes**
Rule: `add-column-not-null-without-default` | Line: 1
```sql
ALTER TABLE users ADD COLUMN email TEXT NOT NULL
Safe alternative: Add column as nullable, backfill, then add NOT NULL constraint
ALTER TABLE users ADD COLUMN email TEXT;
ALTER TABLE users ALTER COLUMN email SET DEFAULT <value>;
UPDATE users SET email = <value> WHERE email IS NULL;
ALTER TABLE users ALTER COLUMN email SET NOT NULL;
## Architecture
migratoor/ src/ sql/ # SQL parsing layer types # Statement, ParsedMigration parser # Split SQL, classify DDL operations rules/ # Safety rules types # Rule, Finding, Severity postgres # 14 PostgreSQL safety rules registry # Rule lookup, list, filter engine/ # Analysis engine analyzer # Apply rules, collect findings, summarize reporter # Format results (structured + markdown) mcp/ # MCP server layer tools/ # 3 MCP tools tests/ # 93 tests mirroring src/ structure
## Prerequisites
- **Node.js** >= 20.0.0
- No other dependencies required — migratoor analyzes SQL statically
## Development
```bash
git clone https://github.com/mrzadexinho/migratoor.git
cd migratoor
npm install
npm run build
npm test
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。