
Migrationpilot
io.github.mickelsamuel由 GitHub 账号 mickelsamuel 发布v1.6.4更新于 Oct 25, 2026
112 rules that catch dangerous PostgreSQL migrations, plus a pass/fail gate to call before any DDL.
概览
一个本地 MCP 服务器,用 112 条规则检查 PostgreSQL 迁移,并在执行 DDL 前为助手提供通过/不通过的关卡。
- 可以做什么
- 在写入或执行 DDL 前对拟议迁移做通过/不通过判定,返回违规项和摘要。分析单个迁移或整个目录,给出规则违规、风险评分和锁分析。查询某条规则的含义及是否可自动修复,并获得自动修复后的 SQL 和仍需人工处理的违规。解释某条 DDL 语句会取得什么锁、会阻塞什么,并列出完整规则目录。
- 适用场景
- 适合助手编写或修改 PostgreSQL 迁移、希望在进入评审或生产前做确定性检查的场景。也适合已在 CI 中把关迁移、希望助手在本地看到相同结论的团队。
- 运行要求
- 通过 npx(包 migrationpilot-mcp)作为本地进程运行,需要 Node.js 22 或更高版本;PostgreSQL 解析器已内置。无需账号、API 密钥或环境变量。配置文件按与 CLI 相同的方式解析,但服务器本身不读取它。
安装
在 SourceWeft 中
- 打开 控制台中的 Migrationpilot,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
MigrationPilot
[npm version] [npm downloads] [CI] [Node] [VS Code] [License: MIT]
Block unsafe Postgres migrations before merge.
Local, deterministic analysis for PostgreSQL migrations. Uses PostgreSQL's parser, checks 112 rules, and exits non-zero in CI. No account required. MIT.
Try it in your browser · GitHub Action · Documentation
Benchmark
56 labelled files. Author-built corpus. Tools pinned.
Methodology · Corpus · What MigrationPilot missed · Reproduce: pnpm build && node bench/run.mjs
A finding
Exit code is 2. The Risk column combines what a statement's lock does with what the rules found in it, so a statement carrying a critical violation reads RED whatever its lock costs. The lock half of that is capped without a database connection — table size and query frequency need one. See Production context.
Contents
Install · AI coding agents · CI · What it checks · Beyond one file · Configuration · Output · Production context · Comparison · Pricing · Architecture · API
Install
Node 22 or newer. The PostgreSQL parser ships compiled in, so there is nothing else to set up. Exit codes are the same everywhere: 0 clean, 1 warnings under --fail-on warning, 2 critical.
Packaged builds land with each release, including single-file executables for Linux, macOS and Windows on the release page for machines without Node. The Windows .exe is not code-signed, so SmartScreen and most browsers will warn about it on download — SHA256SUMS on the same release is how you check you got the file we published, not a signature.
On Windows in Git Bash, MSYS rewrites paths inside the mount flag, so use the Windows-form working directory instead:
AI coding agents
Agents write migrations now. They are good at SQL and bad at knowing which statement takes an ACCESS EXCLUSIVE lock on a table with 40 million rows, and by then the outage has already happened.
MCP server. Seven tools, the important one being check_before_apply: a pass/fail gate the agent calls before it writes or runs DDL. It resolves your .migrationpilotrc.yml exactly like the CLI does, so its verdict is the verdict CI will give.
Claude Code plugin. integrations/claude-code/ pairs a skill that tells Claude to check migrations with a PreToolUse hook that blocks the tool call when it doesn't. It fails open on purpose: a missing install, unparseable SQL, or a timeout lets the call through with a note on stderr, because a guardrail that breaks your workflow when it can't run gets uninstalled.
Cursor and Copilot. Copy integrations/cursor/migrationpilot.mdc into .cursor/rules/, or paste integrations/copilot/copilot-instructions-snippet.md into .github/copilot-instructions.md. Both tell the agent when to run MigrationPilot and that suppressing a rule to get past a violation is the user's call, not the agent's.
CI
GitHub Action
Posts a report as a PR comment, fails the check on critical violations, and writes a SARIF file. To feed it into Code Scanning, add an upload step (needs Advanced Security on private repos):
Without the permissions block the Action still runs. It warns, analyzes every file matching the glob instead of only the ones the PR changed, and skips the comment. The check verdict, the SARIF file and the inline annotations come from the analysis either way.
A migration the Action can't read or parse fails the check, since nothing analyzed it, and the failure names the file and the parser's error. Files that aren't plain SQL, like ones with psql meta-commands or template placeholders, go under ignore in the config. With fail-on: never they're reported and the check passes.
The Action reads the same config file as the CLI, so ignore, rules, failOn, pgVersion and extends all apply there. An input you set in the workflow wins over the config. With an Org license key, so do the config's policy block and audit log, and the policy wins over the inputs: exclude can't drop a required rule, and a blocked statement fails the check even under fail-on: never.
Outputs: risk-level, violations, sarif-file.
Pre-commit
migrationpilot hook install writes a plain git hook and is Husky-aware. With the pre-commit framework instead:
Clean files print nothing. Only migrations with violations are reported.
If pre-commit install answers Cowardly refusing to install hooks with 'core.hooksPath' set, something else already owns your hooks directory — Husky sets it. Check with git config core.hooksPath, then either git config --unset-all core.hooksPath and let pre-commit manage the hooks, or keep Husky and run migrationpilot hook install, which appends to .husky/pre-commit instead of fighting it.
GitLab CI
Runs on merge requests that touch migrations, keeps the JSON report as an artifact, and annotates the MR diff through GitLab Code Quality.
What it checks
112 rules: 34 critical, 78 warning, 20 auto-fixable with --fix. Ten that matter most:
Browse all 112 rules, or run migrationpilot explain MP027 for one. The handbook is 20 chapters on why each hazard bites and what to do instead.
Rules adapt to --pg-version (9 through 18): REINDEX CONCURRENTLY from 12, DETACH PARTITION CONCURRENTLY from 14, the native NOT NULL ... NOT VALID path from 18.
Beyond one file
analyze --fix rewrites the 20 fixable violations in place. The rest of the surface:
Twenty-four commands in total. migrationpilot --help lists them.
Sequence analysis is what a per-file linter cannot see. Three migrations that each look fine can still take one table down together:
Tune it with --lock-budget <seconds> and --hot-table-threshold <files>, turn it off with --no-sequence, and make it blocking with --fail-on-sequence.
--fail-on irreversible is stricter than critical: it also blocks migrations that destroy data with no down file.
Configuration
Zero-config is the default. check with no directory detects your framework, finds its migrations, and analyzes them in apply order. Fourteen are supported: Flyway, Liquibase, Alembic, Django, Knex, Prisma, TypeORM, Drizzle, Sequelize, goose, dbmate, Sqitch, Rails, Ecto. Force one with --framework prisma, or pipe any generator through --from-command:
Five presets: recommended (default), strict, ci, startup, enterprise. Inline, -- migrationpilot-disable MP001 suppresses a rule for the next statement and -- migrationpilot-disable-file MP001 does it for the whole file. Name no rule and it suppresses all of them.
Org policy
With an Org plan key in MIGRATIONPILOT_LICENSE_KEY (or --license-key, or the Action's license-key input), analyze, check, precommit and the Action apply the config's policy block. watch, plan, simulate and mutation-test keep the required rules on and hold the floor too, but only the gates fail on a blocked pattern.
Each override prints a note saying what it kept on. A rule that ships as a warning stays a warning under a critical floor. Patterns match whole words, ignoring case, whitespace and comments. Without a valid key, the run says the policy isn't applied rather than passing quietly. --no-config skips the config file and the policy with it, so enforce from CI, where the config gets reviewed like code. The MCP server doesn't read the config.
Ed25519 license keys validate client-side, with no network call. --offline skips update checks and every other network call. There is no telemetry.
Output
--format text (default), json, sarif, or markdown, plus --quiet for one gcc-style line per violation and --verbose for per-statement pass/fail.
SARIF feeds GitHub Code Scanning, VS Code and IntelliJ: migrationpilot analyze migration.sql --format sarif --output results.sarif.
Production context
Pass --database-url and MigrationPilot opens one read-only connection to read pg_class, pg_stat_statements and pg_stat_activity. It reads no user data and runs no DDL.
That turns risk scoring from a guess into a measurement, and gives three rules the numbers they have nothing to say without: MP013 (DDL on a high-traffic table), MP014 (long-held locks on a table with millions of rows), MP019 (ACCESS EXCLUSIVE while connections are piling up).
GREEN is 0-24, YELLOW 25-49, RED 50-100.
Comparison
Squawk: 40 rules as of v2.62.0 (Aug 2026). Atlas gates migrate lint behind a Pro login in the official binary since v0.38 (Oct 2025); the Community build keeps a basic analyzer set, but the PostgreSQL lock analyzers are Pro-only. It could not be benchmarked without a paid account. The methodology records the exact command and its refusal.
Pricing
Everything the linter does is free and unmetered: all 112 rules including the production-context ones, auto-fix, sequence analysis, simulate, every output format, the GitHub Action, the MCP server. No account, no seat count, no telemetry, MIT.
The $499/year Org plan turns the free linter into an enforceable control: one policy across repositories that developers cannot quietly disable, a JSONL audit trail of every check, and direct support from the maintainer.
Architecture
Programmatic API
Sixty-nine value exports plus full TypeScript types. allRules is the same rule set the CLI runs.
Development
CONTRIBUTING.md · SECURITY.md · CHANGELOG.md
License
MIT
来源:README.md,提交 157bcc5
工具
0版本历史
3- v1.6.4最新Oct 13, 2026
- v1.6.3Oct 13, 2026
- v1.6.1Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分