Skip to content

Output format

Each generated Markdown file documents one database.

Structure

  1. Title — database name and generation metadata
  2. ER diagram — Mermaid erDiagram fenced block
  3. Tables — one section per table

Per-table content

Section Contents
Columns Name, type, nullable, default, PK, comment
Foreign keys Columns → referred table, ON DELETE, constraint name
Unique constraints Column groups
Check constraints Name + SQL text (when available)
Indexes Name, columns, UNIQUE flag

Table comments (when the dialect exposes them) appear under the table heading.

Example sketch

# Database schema — `myapp`

> Auto-generated on 2026-08-02 12:00:00 UTC (schema `public`, 2 table(s)).

## ER diagram

```mermaid
erDiagram
    "users" {
        INTEGER id PK "Primary key"
        VARCHAR(255) email
    }
    "notes" {
        INTEGER id PK
        INTEGER user_id FK
        TEXT body "nullable"
    }
    "users" ||--o{ "notes" : "notes_user_id_fkey"
```

## Tables

### `users`

Application users

| Column | Type | Nullable | Default | PK | Comment |
|---|---|---|---|---|---|
| `id` | `INTEGER` | no | — | yes | Primary key |
| `email` | `VARCHAR(255)` | no | — |  | — |

**Indexes**

- `idx_users_email` (email) UNIQUE

Mermaid markers

Inside entity boxes, attributes follow the type name KEY, KEY "comment" grammar:

Marker Meaning
PK Primary key column
FK Column participates in a foreign key
PK, FK Both — key constraints are comma-separated, as the parser requires
"nullable" Column allows NULL (and is not PK) — compat style
type? Same thing in the optional style

Column comments (when the dialect exposes them) land in the quoted comment slot. Attribute names that fall outside Mermaid's ATTRIBUTE_WORD charset (spaces, a leading digit, %…) are wrapped in backticks — quoting them would make the parser read them as a comment.

Relationship operators (cardinalities) are inferred — see Mermaid cardinalities.

Attribute styles

--er-style (or er_style= in the API) picks how attributes are written:

INTEGER id PK
INTEGER user_id FK
TEXT body "nullable"

Parses on every Mermaid release, including the versions bundled by GitHub and MkDocs Material.

INTEGER id PK
INTEGER user_id FK
TEXT? body

Uses the native optional-type suffix. Requires a recent Mermaid (mermaid-js/mermaid#7319).

INTEGER id
INTEGER user_id
TEXT body

Type and name only — readable diagrams for schemas with many tables.

Limitations

  • Views, materialized views, and sequences are not documented yet (base tables only).
  • Under SQLite, -d / --database does not switch files (one DB per path); a warning is logged.