strabo
Named after the Greek geographer who wrote down the known world. Strabo writes down your database.
Generates a readable record of a Postgres schema from pg_dump: a tidy SQL reference plus DBML, PlantUML and SVG diagrams. Commit the output next to your migrations so people and AI agents can read the schema without a running database.
schema.sql: every enum, table, view, function and trigger, grouped and sorted. Each table carries its constraints, indexes, comments, row level security and policies. It is for reading only, never for running.
.dbml: diagrams for dbdiagram.io, split by domain or by schema. Foreign keys sit on their column, and references to tables outside a diagram stay as comments there. Only composite foreign keys get a standalone Ref:, and only unique indexes not already shown on a column are listed.
.puml: the same diagrams as PlantUML entity-relationship diagrams.
.svg: the DBML diagrams rendered, with the optional @softwaretechnik/dbml-renderer.
Built for local Supabase stacks, and it works with any Postgres that pg_dump can reach.
Install
pnpm add -D @tandemcreativedev/strabo
# only if you want SVG output
pnpm add -D @softwaretechnik/dbml-renderer
You need the PostgreSQL client tools (pg_dump) at the same major version as the server or newer. Without them, point pgDump at the database container (see below).
Use
pnpm strabo init # writes a starter strabo.config.json
pnpm strabo # dumps the local database and writes docs/db/*
pnpm strabo --check # exits 1 if the committed files are out of date
A typical package.json script, run after applying migrations locally:
"db:schema": "strabo"
Options
| Flag |
Meaning |
-c, --config <file> |
Config file. Defaults to strabo.config.json if present. |
-i, --input <file> |
Parse a saved schema-only dump instead of running pg_dump. |
--db-url <url> |
Database to dump. Defaults to local Supabase (127.0.0.1:54322). |
--out <dir> |
Output directory. |
--check |
Compare the output with the files on disk and write nothing. |
--allow-remote |
Allow a database that is not on this machine. Refused by default. |
Config
strabo.config.json, with every field optional:
{
"databaseUrl": "postgresql://postgres:postgres@127.0.0.1:54322/postgres",
"schemas": ["public", "private", "audit"],
"outDir": "docs/db",
"sql": "schema.sql",
"pgDump": "pg_dump",
"diagrams": [
{ "name": "schema", "title": "Everything public", "schemas": ["public", "private"], "formats": ["dbml", "svg"] },
{ "name": "schema-audit", "title": "Audit log", "schemas": ["audit"] },
{
"name": "diagrams/01_tenancy",
"title": "Tenancy and access control",
"notes": ["Profiles extend auth.users one-to-one"],
"tables": ["tenants", "roles", "tenant_*", "profiles", "audit.log_tenant_*"],
"formats": ["dbml", "puml"]
}
],
"hiddenRefs": {
"public.passages.document_id": "denormalised ref to documents.id"
}
}
schemas: the schemas to dump. Names in the first one appear without a prefix (users, not public.users). Other schemas keep theirs (audit.events).
sql: the SQL reference's file name, or false to skip it.
diagrams: one entry per diagram. name is the output path without an extension, relative to outDir.
tables lists the tables to draw, in drawing order. Bare names belong to the first schema, and * is a wildcard. When any diagram uses tables, the run warns about tables that no diagram lists, so new tables don't go undocumented.
- Without
tables, a diagram draws every table in schemas, or in every dumped schema if schemas is also absent.
enums: false leaves enum definitions out, such as when another diagram already lists them.
formats takes any of dbml (the default), puml and svg.
hiddenRefs: foreign keys to leave out of diagrams, each with a note to show on the column instead. Useful for denormalised columns that would tangle a diagram.
pgDump: the command that runs pg_dump. Without local client tools, use the Supabase container: "docker exec supabase_db_<project> pg_dump", with databaseUrl set to postgresql://postgres:postgres@localhost:5432/postgres, which is the address inside the container.
Programmatic use
import { generate, resolveConfig } from "@tandemcreativedev/strabo";
const { files, warnings } = generate(dumpText, resolveConfig({ schemas: ["public"] }));
parseDump, buildDiagram, writeSql, writeDbml, writePuml and writeSvg are exported too, for custom output.
Releasing
Releases are cut by release-please from conventional commit messages. Each push to main updates a release pull request that bumps the version in package.json and adds the changes to CHANGELOG.md. Merging that pull request tags the release and publishes it to npm through trusted publishing, with no token stored in the repo. While the version is 0.x, breaking changes bump the minor version.
Development
pnpm test # parser and writer tests against test/fixtures/dump.sql
UPDATE_EXPECTED=1 pnpm test # accept output changes into test/fixtures/expected
pnpm fixture # rebuild the fixture dump from fixture.ddl.sql (needs local Supabase)
The parser reads pg_dump's plain-text output. It splits the dump on the -- Name: …; Type: … header that pg_dump writes before every object, then parses each statement on its own. It is tested against pg_dump 18 output.