Skip to main content

Schema Impact Map

An impact-aware map of relational data assets.

ci pages

Repository: sunzhongding/schema-impact-map · CLI: schema-impact-map · Python: schema_impact_map

Schema Impact Map turns a relational schema into a single interactive map of databases, tables and columns, connects the columns that reference each other, and highlights what a proposed change will break — in red, orange and yellow.

Schema Impact Map

Most schema tools draw an ERD. Schema Impact Map answers a different question:

If I change this column, which fields, relationships and SQL statements are affected?

It is designed for the workflow where an AI agent proposes a change, a human reviews it, and the change lands in a migration or a mapper. The map and the impact report are static HTML — no server, no credentials in the browser, no database connection required to view.

Why

  • Relational schemas are assets, but their relationships rarely live in one place.
  • Many production databases have no foreign keys; relationships live in SQL, naming and data.
  • AI makes schema changes cheap to propose and expensive to review. Review needs evidence.

It keeps the evidence:

Evidence Meaning Typical confidence
fk declared foreign key 1.0
sql_join a join that really exists in code 0.9
value_overlap values of a child column overlap a parent key 0.9–0.95
same_entity a human decided two columns are the same entity 1.0

Cross-database edges are first-class: the demo has shop, crm, billing and ops databases connected by declared relationships and SQL joins.

Quick start

git clone https://github.com/sunzhongding/schema-impact-map.git
cd schema-impact-map

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

schema-impact-map demo
open site/index.html

No database is needed. The demo is generated from the synthetic files in examples/shop.

Page What it shows
site/index.html interactive map: drag, zoom, search, fit
site/impact.html impact of changing crm.customers.id: 3 affected columns, 2 SQL statements
site/impact-refund.html adding shop.refunds.status: collisions with existing status columns

Impact map

How it works

examples/shop/
├── schema.json       physical schema + declared relations (synthetic)
├── entities.yaml     human decisions: customer / order / agent
├── rules.yaml        what is not a relationship
├── sql/*.sql         joins that really exist in code
└── plans/*.yaml      proposed changes (what-if input)

        │
        ▼

schema-impact-map build ──► graph.json ──┬──► schema-impact-map map    ──► interactive HTML
                                         └──► schema-impact-map impact ──► highlighted HTML

1. Schema + relations

schema.json lists databases, tables, columns, keys and declared relations. Relations can cross databases; the demo does exactly that.

2. SQL joins

sql.py parses every .sql file with sqlglot, resolves table aliases, and extracts column-level join predicates. A declared FK and a SQL join for the same pair are merged into one edge with confidence 1.0.

3. Entities

entities.yaml is the human layer:

entities:
  customer:
    canonical: crm.customers.id
    aliases:
      - shop.orders.customer_id
      - billing.invoices.customer_id

The map marks C (canonical), A (alias) and K (business key). The check fails if a *_id column has no relation and no entity declaration.

4. Impact

A plan is a small YAML file:

name: Review customer key
changes:
  analyze_columns:
    - crm.customers.id
schema-impact-map impact --plan examples/shop/plans/customer-key.yaml --out site/impact.html

Colors:

  • red: changed column, breaking impact, impacted relationship, affected table/database
  • orange: new column, affected column
  • yellow: naming/semantic collision with an existing column
  • red dashed: relationship proposed by the plan

The right panel lists changed columns, affected columns, collisions, affected SQL and tables. Click any item to focus it. “Impact only” fades everything unrelated.

Input layout

A data directory is just text:

# schema-impact-map.yaml
name: shop-demo
dialect: mysql
default_database: shop
schema: schema.json
entities: entities.yaml
rules: rules.yaml
sql: sql
  • schema.json: databases → tables → columns, plus declared relations
  • entities.yaml: canonical / aliases / business keys (human decisions)
  • rules.yaml: *_id patterns and columns that are not relationships
  • sql/: .sql files whose joins are parsed into field-level edges
  • plans/: YAML deltas for schema-impact-map impact

Commands

schema-impact-map build  --data examples/shop --out dist
schema-impact-map map    --data examples/shop --out site/map.html
schema-impact-map impact --data examples/shop --plan examples/shop/plans/customer-key.yaml \
                          --out site/impact.html
schema-impact-map check  --data examples/shop
schema-impact-map demo   --data examples/shop --out site
schema-impact-map mcp    # serve the MCP tools over stdio

check validates:

  • every declared relation points to a real column
  • every entity member exists
  • every *_id column is explained by a relation or an entity (or ignored with a reason)

Use it from your agent

The same graph is available inside AI coding clients: a stdio MCP server, plus a plugin package that Claude Code and ZCode load directly and a SKILL.md that Codex and WorkBuddy pick up.

uv tool install "schema-impact-map[mcp]"   # or: pipx install "schema-impact-map[mcp]"
schema-impact-map mcp                      # MCP tools: check, impact, render, build_graph
Client What to install Guide
Claude Code /plugin marketplace add sunzhongding/schema-impact-map → /plugin install schema-impact-map@schema-impact-map docs/integrations/claude-code.md
Codex MCP entry in ~/.codex/config.toml + skill in ~/.codex/skills/ docs/integrations/codex.md
ZCode add this repository as a plugin market docs/integrations/zcode.md
WorkBuddy ~/.workbuddy/mcp.json + skill upload docs/integrations/workbuddy.md

All four tools are local and read-only: they read the ledger, parse SQL text, and write at most the HTML page you asked for. No database connection, no credentials, no network.

What this is / is not

This is:

  • a static HTML map you can open locally or publish on GitHub Pages
  • an impact view driven by the same graph as the map
  • a small, auditable model (schema.json + entities.yaml + rules.yaml)

This is not (yet):

  • a full data catalog or governance platform
  • a live database scanner — v0.1 reads a schema JSON; a MySQL/PostgreSQL connector is on the roadmap
  • a runtime lineage tool — it reasons over schema + SQL text, not query logs
  • a complete SQL parser — complex/dynamic SQL should be added as test fixtures

Multi-database roadmap

The demo already models four databases and cross-database relations. The next steps:

Version Scope
0.1 demo schema JSON, SQL files, entity map, impact map (this release)
0.2 MySQL + PostgreSQL connectors; same-instance cross-schema
0.3 cross-instance value-overlap probing (sampling to DuckDB/Arrow), not full data pulls
0.4 runtime evidence (query logs / audit) and a GitHub Action that posts an impact map on PRs

The qualified name is designed to grow from database.table.column to instance.database.schema.table.column; see docs/design.md.

Security

  • The demo contains only synthetic data.
  • The tool never stores database credentials.
  • The generated HTML is self-contained (no CDN, no telemetry).
  • The map only contains schema names and declared relations, not row values.

Contributing

See CONTRIBUTING.md. Good first issues: add a MySQL connector, add a MyBatis XML extractor, add a PostgreSQL test fixture, improve the map layout.

中文简介

Schema Impact Map 把关系型数据库的库、表、字段画成一张可拖拽/缩放的地图,并把字段之间的关系连起来。 给一个“方案变更” YAML,它会把受影响的字段、关系边和 SQL 用红/橙/黄标出来。

schema-impact-map demo
open site/index.html      # 交互地图
open site/impact.html     # 影响高亮

当前 v0.1 用 examples/shop 的合成数据,不连接任何真实数据库。后续会加 MySQL/PostgreSQL 连接器和跨库值域探查。

License

Apache-2.0. See LICENSE.

Metadata

Release files for schema-impact-map 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for schema-impact-map 0.2.0
File Size Uploaded Provenance Actions
schema_impact_map-0.2.0.tar.gz 275.2 kB With provenance Details for schema_impact_map-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for schema-impact-map 0.2.0
File Interpreter ABI Platform Actions
schema_impact_map-0.2.0-py3-none-any.whl Python 3 none any Details for schema_impact_map-0.2.0-py3-none-any.whl

Total release size: 305.4 kB

Release files / schema_impact_map-0.2.0.tar.gz

Download URL schema_impact_map-0.2.0.tar.gz
Size 275.2 kB
Tags Source
SHA-256 checksum
How to use checksums
04a1e735d93085ca992aa520368a8b988c924096d477b53953a1ca0758843040
BLAKE2b-256 checksum
How to use checksums
c389894330d7729ba5b71255cb7fb17920764481dab84538ad5b22cdf384c9c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Release files / schema_impact_map-0.2.0-py3-none-any.whl

Download URL schema_impact_map-0.2.0-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b36e1950eb83929310e210aeadc92d085a5dae5429b8aa545e9706df589df6fb
BLAKE2b-256 checksum
How to use checksums
70bfee0388145ea697ca162d74d1ed606055ac51dbad4dfcb670b13dd4ab3603
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

Security for schema-impact-map 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for schema_impact_map-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page