DeltaScope 是一个离线优先的 MySQL DDL审核工具,用于 SQL 上线审核。它在 ALTER TABLE、CREATE TABLE 等表结构变更真正执行之前,解析 SQL 文本并评估风险规则,给出 blocker、warning、notice 三级结论。DeltaScope 不连接生产数据库,默认离线审核。
将一条或多条 MySQL DDL 语句传给 DeltaScope,它会解析 SQL、评估所有适用规则,返回结构化审核结果。整个过程无需数据库连接。
$ deltascope audit --sql "ALTER TABLE users DROP COLUMN age;"
Verdict: reject
Statements: 1
Blockers: 1
Warnings: 0
Notices: 0
Statement 1: ALTER TABLE
- [blocker] ddl.alter.drop.column: dropping column "age" is a destructive change
DeltaScope 提供 CLI、CI 集成、HTTP 服务、Go SDK、MCP 服务五种入口,全部使用同一套审核引擎。
# GitHub Actions
- name: Audit SQL migrations
run: |
deltascope audit \
--file ./migrations/20260409_drop_column.sql \
--format github-actions \
--fail-on blocker
也支持 --format sarif(GitHub Code Scanning)和 --format gitlab-codequality(GitLab CI)。
deltascope rules 查看完整规则列表。--config 指定。--dialect tidb 切换到 TiDB 解析和规则。CLI、CI、HTTP、MCP 都同时支持 MySQL 和 TiDB。