Skip to content

stratum

Static PostgreSQL migrations → Mermaid ERD.
No database, no cgo, no network.

Get started See a live ERD

  • No database


    Replays your migrations against an in-memory model. Nothing to provision, seed or tear down in CI.

  • Pure Go, one binary


    A hand-written DDL parser with no cgo and no third-party SQL library. CGO_ENABLED=0 just works.

  • Deterministic


    The same migrations always render the same document, which is what makes the --check CI gate possible.

  • Built for CI


    Ships as a GitHub Action: push regenerated docs, or fail the pull request when they're stale.

How it works

flowchart LR
  A["migrations/*.sql"] --> B["Lexer"]
  B --> C["DDL parser"]
  C --> D[("In-memory schema")]
  D --> E["Mermaid ERD + Markdown"]

Migrations are applied in order, so ALTER, RENAME and DROP behave like they do in a real database: the diagram shows the schema as it exists after the last migration. Statements the parser doesn't model (DML, DO blocks, functions) are skipped, never fatal. See Parser for the details.

Quick start

go install github.com/zvdy/stratum/cmd/stratum@latest
stratum --migrations-path db/migrations --output SCHEMA.md
- uses: actions/checkout@v4
- uses: zvdy/stratum@main
  with:
    migrations-path: db/migrations
    output: SCHEMA.md
    check: "true"
docker build -t stratum .
docker run --rm -v "$PWD:/work" -w /work stratum \
  --migrations-path db/migrations --output SCHEMA.md

See it in action

The live example is generated by stratum itself, from this repository's test migrations, every time the site deploys.