Schema diff & ER diagram on every pull request
A free GitHub Action that comments what your migration changed — added and dropped tables, column changes, a ready-to-review ALTER preview, and a Mermaid ER diagram — the moment a PR touches Postgres migrations. No database, no API keys.
Reads files, not databases
Parses migrations at the base and head commits inside the CI runner. Nothing is executed, no credentials exist.
One sticky comment
Every push updates the same comment — the current diff is always the latest, never buried under spam.
Migration preview included
ALTER TABLE statements with backfill and drop-dependency warnings, so reviewers see the plan with the diff.
What the comment looks like
📊 Schema diff
_Migration files changed: 2 (1 added, 1 modified) — `a7367ba` → `f665d09`._
| Change | Table | Details |
|---|---|---|
| ➕ added | products | 3 columns |
| ✏️ changed | users | +1 col (name) |
| ✏️ changed | orders | +2 col (status, product_id) · +1 FK |
💾 Migration preview (ALTER TABLE + safety notes)
🗺️ ER diagram (head) — renders natively on GitHub
Free tool by dbdiagramr — paste your connection string, get the live ER diagram in 10s
Real output from a live test PR →
Add it to your repo in 30 seconds
Drop this workflow into .github/workflows/. That is the whole install — no app to authorize, no service to sign up for.
# .github/workflows/schema-diff.yml
name: Schema diff
on:
pull_request:
paths:
- "**/migrations/**/*.sql"
permissions:
contents: read
pull-requests: write
jobs:
schema-diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # the action reads the base commit
- uses: VarunKvK/dbdiagramr/actions/pr-schema-diff-erd@mainAdvanced: set the migrations-path input to match your folder (for example db/migration/*.sql for Flyway).
Keep the ER diagram in your README
Add readme-path: README.md and grant contents: write. The action rewrites a marked Mermaid block with the head schema and commits it to the PR branch. Repeat runs only touch that block, and nothing is committed when the diagram is unchanged.
# Same action, plus a committed ER diagram in README.md
permissions:
contents: write # commit the README block
pull-requests: write # post the diff comment
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: VarunKvK/dbdiagramr/actions/pr-schema-diff-erd@main
with:
readme-path: README.mdThe block is wrapped in <!-- dbdiagramr:erd:start --> and <!-- dbdiagramr:erd:end -->. If the markers are missing, the action appends a “Database schema” section. Fork PRs are skipped because the token cannot write to the fork.
What it does not do (v1)
- · Postgres DDL only — MySQL and SQLite dialects are not parsed yet.
- · .sql migrations only — knex and Prisma .js migration files are skipped.
- · Best-effort parser: anything it cannot read is flagged in the comment, not hidden.
- · Fork PRs: the read-only token cannot post comments (see FAQ).
Want the same diff in the browser on two pasted schemas? Use Schema Diff →
Frequently asked questions
Related tools
Turn it into an ER diagram
Paste your PostgreSQL connection string and get an interactive ER diagram of your own schema in under 10 seconds. No signup required.