← All tools
GitHub Action

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

dbdiagramr[bot] commented · updates on every push

📊 Schema diff

_Migration files changed: 2 (1 added, 1 modified) — `a7367ba` → `f665d09`._

ChangeTableDetails
➕ addedproducts3 columns
✏️ changedusers+1 col (name)
✏️ changedorders+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@main

Advanced: set the migrations-path input to match your folder (for example db/migration/*.sql for Flyway).

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

Does the Action need a database or credentials?

No. It reads your migration .sql files at the base and head commits and parses them locally in the CI runner. No Postgres, no Neon account, no connection string, nothing executed.

Which files does it look at?

SQL files matching the migrations-path input, default **/migrations/**/*.sql. Change the glob for Flyway (db/migration), Liquibase, or any folder you keep DDL in.

Will it spam my pull requests?

No. It posts one comment with a hidden marker and updates that same comment on every push — reviewers get a single, always-current diff.

What SQL does it understand?

PostgreSQL DDL: CREATE TABLE, ALTER TABLE, columns, primary keys, foreign keys, defaults, and nullability. Knex or Prisma .js migrations are skipped — keep migrations as .sql files.

What about pull requests from forks?

Fork PRs receive a read-only token, so the action runs the diff but cannot post a comment. Same-repo branches work out of the box with the permissions block in the README.

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.