@picadeck/drizzle-parser
Parse Drizzle ORM schema objects into a UniversalSchema for visualization.
Installation
npm install @picadeck/drizzle-parserImport
import { parseDrizzleSchema } from "@picadeck/drizzle-parser";API
parseDrizzleSchema(schema: Record<string, any>, database?: "postgresql" | "mysql" | "sqlite"): UniversalSchema
Accepts an object containing Drizzle table definitions (the result of calling pgTable, mysqlTable, or sqliteTable). The optional database parameter helps with type normalization.
Full Example
server.ts
import express from "express";
import { schemaVisualizer } from "@picadeck/core";
import { parseDrizzleSchema } from "@picadeck/drizzle-parser";
import * as schema from "./db/schema";
// schema.ts exports:
// export const users = pgTable("users", { ... });
// export const posts = pgTable("posts", { ... });
const app = express();
const universalSchema = parseDrizzleSchema(schema, "postgresql");
app.use("/schema", schemaVisualizer(universalSchema));
app.listen(3000, () => {
console.log("Schema visualizer at http://localhost:3000/schema");
});Supported Types
| Drizzle Column Type | NormalizedType |
|---|---|
| text / varchar | STRING |
| integer / serial | INTEGER |
| real / doublePrecision | FLOAT |
| numeric / decimal | DECIMAL |
| boolean | BOOLEAN |
| timestamp / date | DATETIME / DATE |
| uuid | UUID |
| json / jsonb | JSON |
| pgEnum / mysqlEnum | ENUM |
Notes
- Drizzle schemas are plain TypeScript objects, so no special runtime setup is needed.
- Foreign key references defined with
.references()are detected as relationships. - Supports PostgreSQL, MySQL, and SQLite Drizzle dialects.