Registry / devops / drizzle-dbml-generator

drizzle-dbml-generator

JSON →
library0.10.0jsnpmunverified

Converts Drizzle ORM schema definitions into DBML (Database Markup Language) markup for visual database design and documentation. Currently at version 0.10.0, this package supports all Drizzle dialects (PostgreSQL, MySQL, SQLite) and generates table definitions with columns, primary keys, foreign keys, unique constraints, indexes, and relations. It requires drizzle-orm >=0.36.0 and tsx for execution. Unlike manual DBML editing, this generator ensures your schema documentation stays in sync with your code. Ships TypeScript types.

npm install drizzle-dbml-generator
INSTALL
IMPORT
SIG · DRIZZLE-DBML-GENER
D
drizzle-dbml-generator
devopsjavascriptv0.10.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pgGenerate
import { pgGenerate } from 'drizzle-dbml-generator';
const pgGenerate = require('drizzle-dbml-generator');
ESM-only; CommonJS require() will fail unless using a bundler that compiles ESM. For MySQL use `mysqlGenerate`, for SQLite use `sqliteGenerate`.
mysqlGenerate
import { mysqlGenerate } from 'drizzle-dbml-generator';
Use for MySQL/MariaDB schemas; same interface as pgGenerate.
sqliteGenerate
import { sqliteGenerate } from 'drizzle-dbml-generator';
Use for SQLite schemas; same interface as pgGenerate.

Shows how to generate a DBML file from a Drizzle ORM schema using a script executed with tsx.

// dbml-generate.ts import * as schema from './schema'; import { pgGenerate } from 'drizzle-dbml-generator'; const out = './schema.dbml'; const relational = true; pgGenerate({ schema, out, relational }); // Run with: tsx dbml-generate.ts // Requires schema.ts with Drizzle ORM table definitions
Debug
Known issues
breakingThe package requires drizzle-orm >=0.36.0. Using an older version will cause type errors or missing exports.
fix
Upgrade drizzle-orm to version 0.36.0 or higher.
affects: >=0.10.0
deprecatedThe relational option defaults to true; setting it to false is not recommended and may be removed in future versions.
fix
Avoid using `relational: false`; if needed, continue using it but be aware it may break.
affects: >=0.9.0
gotchaThe generator only works with Drizzle ORM schema objects, not with direct table definitions from database introspection.
fix
Define your schema using Drizzle ORM's pgTable, mysqlTable, etc. and export it as a single object.
affects: *
gotchaCommonJS require() will fail because the package is ESM-only. Use dynamic import() if you must use require.
fix
Use ESM imports in your script or configure tsx to handle TypeScript correctly.
affects: >=0.10.0
Errors
Common errors & fixes
Cannot find module 'drizzle-dbml-generator'
The package is not installed or not in the current project's node_modules.
fix
Run: npm install -D drizzle-dbml-generator
The requested module 'drizzle-dbml-generator' does not provide an export named 'pgGenerate'
Using an old version of the package (pre-0.10.0) which had different exports.
fix
Update to version >=0.10.0: npm install -D drizzle-dbml-generator@latest
TypeError: (0 , drizzle_dbml_generator_1.pgGenerate) is not a function
Attempting to use CommonJS require() on an ESM-only package.
fix
Change to ESM import: import { pgGenerate } from 'drizzle-dbml-generator';
Upgrade
Version history
0.10.0latest on npm
Audit
Dependencies
drizzle-ormrequiredPeer dependency required to access Drizzle schema types and table definitions
tsxoptionalRequired to run the generation script as TypeScript directly; not a direct dependency but commonly installed for execution
Agent activity
13 hits · last 30 days
node
12
Resources
drizzle-dbml-generator — npm install drizzle-dbml-generator · libregistry