
orm-preflight
io.github.sikandar100由 GitHub 帳號 sikandar100 發布v1.2.0更新於 Oct 24, 2026
Checks TypeORM migrations for data loss, table locks, and deploy problems before they run.
發布方自己的服務:Preflight
概覽
本機 MCP 伺服器,讓 AI 程式助理在合併前靜態檢查 TypeORM 遷移中的資料遺失、資料表鎖定與部署風險。
- 可以做什麼
- 檢查遷移:對指定檔案、整個專案或自某個 git 參照以來變更的遷移執行安全規則,每筆結果說明會發生什麼、原因以及安全做法。查詢規則:讀取單一規則的完整文件,或列出所有規則及其分類與預設嚴重等級。檢查範圍涵蓋資料遺失、部署安全、PostgreSQL 鎖定與正確性,工具只讀取檔案。
- 適用情境
- 當助理撰寫或修改 TypeORM 遷移,而你希望在審查或合併前找出危險變更時使用,特別適合已有資料的 PostgreSQL 或 MySQL 專案。也適合希望助理自行檢查並修正遷移、不必人工閱讀警告的團隊。
- 執行需求
- 透過 npx orm-preflight mcp 以 stdio 在本機執行,需要 Node.js 20 或更新版本。不需要資料庫、帳號、API 金鑰或環境變數。使用 MySQL 時,需在專案中安裝 orm-preflight 與 node-sql-parser,並去掉 -y 參數執行指令。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 orm-preflight,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
orm-preflight
[npm] [CI] [OpenSSF Scorecard] [License: MIT]
Preflight safety checks for TypeORM migrations: catch data loss and locking before you merge.
Documentation: https://sikandar100.github.io/orm-preflight/
Changing a column's length in TypeORM can delete all of its data. When a column's type or length changes, TypeORM's migration generator drops the column and adds it again (typeorm/typeorm#3357). The migration looks harmless in review and passes every test on an empty database. orm-preflight catches that, and other migrations that lose data, lock busy tables, or break a rolling deploy, before you merge.
Install and run
Node.js 20 or newer. Without arguments, orm-preflight checks the migrations globs from its
config, or every migrations folder in the project.
To start on an existing project without fixing its history, run npx orm-preflight init first
(see Adopting on an existing project).
What it catches
Every finding says what happens, why, and how to make the change safely. Each rule's page cites
the PostgreSQL, MySQL, or TypeORM source behind its claim. Run npx orm-preflight explain <rule>
to read it in the terminal, or npx orm-preflight rules for the list.
Changes to a table created in the same migration are not reported: it has no rows yet.
Command line
Configuration
Put the config in orm-preflight.config.json, or under the "ormPreflight" key of
package.json. Only JSON is supported, so a pull request cannot run code through the config.
Command-line flags override the config.
What each severity does:
Adopting on an existing project
init writes orm-preflight.config.json with startAfter set to your newest migration, so only
migrations you add from now on are checked. It reads your migration files but never runs them.
On pull requests, you can also check only the migrations the branch adds or changes:
It compares against the merge base with origin/main and includes uncommitted and untracked
files. Tables created by any of the changed migrations count as new for all of them. Editing a
migration that already exists on origin/main is reported by no-edit-applied-migration. In
GitHub Actions, check out with fetch-depth: 0 so the merge base is available.
Continuous integration
orm-preflight needs no database and no secrets, so it is safe on pull requests from forks.
GitHub Action
Findings appear as annotations on the exact lines of the pull request:
Which version to use:
@v1follows every 1.x release, so you get fixes without changing anything.@v1.0.0, or a commit SHA, stays exactly where it is, if your policy requires pinning.
The action installs the orm-preflight version of its tag with npm and runs it, so GitHub-hosted runners need nothing else. On a self-hosted runner, set up Node.js 20 or newer first.
Use the pull_request trigger. Never use pull_request_target for this: it gives pull requests
from forks a token with write access and your secrets, and orm-preflight needs neither.
GitHub shows at most 10 annotations of each level per step. The last line of the log always counts every finding.
To see findings in the repository's code scanning alerts as well, set sarif: true and grant
security-events: write. GitHub never grants that to pull requests from forks, so the action
skips the upload there and still annotates:
Other CI systems
Run the CLI. The exit code is 1 when there are errors:
Check out enough history for the merge base (in GitHub Actions, fetch-depth: 0).
Use it from an AI coding agent
AI coding agents write migrations fast, and they can write the dangerous ones too. With orm-preflight connected, the agent checks each migration it writes and fixes what it finds, before you review anything.
Claude Code plugin
The plugin does the most for you. Install it once, inside Claude Code:
It adds three things:
- An automatic check. Every time Claude writes or edits a migration, orm-preflight checks it and hands the result straight back to Claude. Claude then fixes the migration, or tells you why it is safe. You do not have to read any warnings yourself. Other files are skipped instantly.
- A skill that teaches Claude the safe ways to change a schema, such as changing a column in place instead of dropping it.
- The MCP tools described below.
The plugin runs the exact orm-preflight version it was released with, downloaded from npm on
first use. Your project's orm-preflight.config.json still applies. To make the automatic
check run the orm-preflight installed in your project instead, for example to use its MySQL
parser, turn on the plugin setting Use the project's own orm-preflight in /config.
Any agent, with MCP
orm-preflight mcp runs orm-preflight as an MCP server.
MCP is the standard way to give an agent new tools. Add it once.
In Claude Code, without the plugin:
In other agents, such as Cursor, VS Code, Codex, or Gemini CLI, add a server to the MCP settings that runs this command. Each app has its own settings file, but the command is always the same:
The exact setup for each agent, and an instructions snippet for AGENTS.md, are in
Use with AI agents.
The agent gets three tools:
Good to know:
- The tools only read files. They never run a migration or connect to a database, and
--executeis not available through MCP. - The server checks the project it was started in. An agent that starts it somewhere else
can pass
projectDir. - Flags after
mcpset the defaults, for examplenpx -y orm-preflight mcp --dialect mysql. For MySQL, installorm-preflightandnode-sql-parserin the project and usenpx orm-preflight mcpwithout-y, so the parser is found. - The server tells the agent never to add a suppression comment without asking you first.
- Your agent may ask you once to allow the tools.
Suppressing a finding
When a finding is expected, say why in a comment above the statement:
The reason is required, so suppressions form an audit trail. For a whole file, put
/* preflight safety-assured-file <rule> -- <reason> */ anywhere in it. A suppression with no reason or an unknown
rule is itself an error.
How it works
orm-preflight parses each migration file with Babel and reads the SQL strings passed to
queryRunner.query() and the builder calls such as addColumn() and createIndex(). It also
fills in ${...} in SQL when the value is known in the same file, such as a constant, a local
function called with fixed arguments, or .join() on a known array, and it reads a loop over a
known array once per item. It parses
the SQL with the PostgreSQL parser (libpg-query) or a MySQL parser, and runs its rules on the
result.
It never imports or runs your migrations, never connects to a database, and never loads
TypeORM. Anything it cannot read, such as SQL built at run time, is reported as
unanalyzable-statement instead of being skipped silently.
Running migrations with --execute
Some migrations build their SQL from values that are only known at run time, for example names
read from the database, or a helper imported from another file. Static analysis cannot read that
SQL. --execute can:
It loads each migration file and runs up() with a stand-in for TypeORM's query runner, which
records every statement instead of sending it to a database. So:
- No database is needed, and none is touched.
- Imports of
typeormget a small stand-in; the real TypeORM is never loaded. - If
up()reads the database, for example withgetTable(), it gets an empty answer, and orm-preflight reports that a real database may lead to different statements. - If
up()fails or runs longer than 10 seconds, that is reported, and linting goes on.
--execute runs your code. Only use it on code you trust:
- Never use it on pull requests from forks with the
pull_request_targettrigger, which gives them your secrets. orm-preflight refuses to, unless you add--allow-untrusted-execute. - The GitHub Action never uses
--execute. It stays static and safe for forks.
What a clean run means
A clean run means none of the documented hazards were found. It does not guarantee that a migration is safe. orm-preflight does not know your table sizes or traffic, so it assumes every existing table is large and busy.
Limitations:
- TypeORM only. The core is ORM-agnostic, so adapters for other ORMs can follow.
- PostgreSQL and MySQL. On MySQL, the data-loss, deploy-safety, and correctness rules apply.
Locking analysis for MySQL (
ALGORITHM=INSTANT,INPLACE,COPY) is planned after 1.0. MySQL needsnpm install --save-dev node-sql-parser. - Only
up()is analyzed.down()is only checked for being empty (require-down). - SQL built at run time is reported, not analyzed, unless you use
--execute.
Programmatic use
Contributing
See CONTRIBUTING.md. To report a security issue, see SECURITY.md.
Privacy
orm-preflight collects nothing and sends nothing: no telemetry, no analytics, no accounts. It runs on your machine or CI runner and never connects to your database. The details are in the privacy policy.
Acknowledgements
orm-preflight is inspired by strong_migrations for Rails and squawk for PostgreSQL.
License
來源:README.md,提交 66f9baf
工具
0版本歷史
2- v1.2.0最新Oct 15, 2026
- v1.1.0Sep 30, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
其他 Preflight 整合
Preflight
social.preflight官方發布者
託管式社群媒體排程伺服器,讓助理起草、依規則檢查、排程並發佈貼文到 12 個平台。

Preflight
由 GitHub 帳號 dainidude 發布
遠端 MCP 伺服器,讓助理按次付費進行智慧合約安全檢查:Solidity 掃描、交易模擬與代幣風險判定。

CSV Contract Preflight MCP
由 GitHub 帳號 anytine123 發布
本機 MCP 伺服器,協助代理起草、審閱並接受 CSV 契約範本,然後購買並彙總付費的 CSV 驗證報告。

PayStage Preflight
由 GitHub 帳號 base-buzz 發布
本機 stdio MCP 伺服器,在代理付款前用 JSON 消費策略檢核 x402 PaymentRequired 內容,回傳 pay、review 或 do_not_pay。

SQLite rebuild copy-map preflight
由 GitHub 帳號 showflexinc 發布
遠端預檢服務,在執行重建前檢查 SQLite 資料表重建複製對應的結構。