DEV Community

Cover image for Keep an ER diagram of your database, updated on every push
Patu
Patu

Posted on Originally published at blog.mcdview.dev

Keep an ER diagram of your database, updated on every push

Paste a SQL schema, get an interactive entity-relationship diagram on a stable link. Wire it into CI and the diagram regenerates itself every time the schema changes: no diagram to draw, ever again.

The Chinook schema as one explorable page

The problem with hand-drawn diagrams

A database diagram is out of date the moment someone adds a column. You draw it once for the onboarding doc, and three migrations later it lies.

mcdview takes the opposite route: the schema file is the source of truth. Point it at your schema.sql and it generates the diagram: a single self-contained HTML page, no runtime, no database connection.

What the diagram does

Every table and relationship is interactive: click a table to isolate it, highlight the hub tables everything depends on, surface dependency cycles, flip between light and dark. You can export the same model as SVG, a Mermaid erDiagram, or a Markdown data dictionary.

Isolating a table

Put it in CI: the diagram updates itself

Your schema lives in the repo. On every push that touches it, CI sends the file to mcdview.dev, which regenerates the diagram behind the same stable link. Bookmark it once; it is always current.

GitHub Actions

name: er-diagram
on:
  push:
    branches: [main]
    paths: [db/schema.sql]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: Gheop/mcdview-action@v1
        with:
          file: db/schema.sql
          key: ${{ secrets.MCDVIEW_KEY }}
Enter fullscreen mode Exit fullscreen mode

GitLab CI

include:
  - component: gitlab.com/Gheop/mcdview/mcdview@~latest
    inputs:
      file: db/schema.sql
      key: $MCDVIEW_KEY
Enter fullscreen mode Exit fullscreen mode

No secret to manage? Use oidc: true instead of a key: the pipeline proves its own identity with a signed token, and the diagram is bound to that project.

include:
  - component: gitlab.com/Gheop/mcdview/mcdview@~latest
    inputs:
      file: db/schema.sql
      oidc: true
Enter fullscreen mode Exit fullscreen mode

A badge for your README

[![mcdview](https://mcdview.dev/badge/<token>.svg)](https://mcdview.dev/v/<token>)
Enter fullscreen mode Exit fullscreen mode

Diff between two versions

What makes it different

Three things you rarely get in one tool:

  • One file, no account. Paste a schema, get a link. The page is a single static HTML file: nothing runs when you open it, no database is contacted, nothing to sign up for.
  • It lives in CI. A GitHub Action or GitLab component regenerates the diagram on every push, behind the same stable link, with a README badge. Zero-key with OIDC.
  • It remembers. Every push is a version: scrub the time-lapse, diff any two states, see what a migration changed.

On top of that: isolate a table, spot hub tables and cycles, switch light or dark, and export to SVG, Mermaid or a Markdown data dictionary.

Try it in 30 seconds

No sign-up. Open mcdview.dev. Supports PostgreSQL, MySQL, SQLite dumps, pgModeler .dbm, DBML and Prisma.

Top comments (0)