PicaDeckSync

Databases, by design.

@picadeck/drizzle-parser

Parse Drizzle ORM schema objects into a UniversalSchema for visualization.

Installation

npm install @picadeck/drizzle-parser

Import

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 TypeNormalizedType
text / varcharSTRING
integer / serialINTEGER
real / doublePrecisionFLOAT
numeric / decimalDECIMAL
booleanBOOLEAN
timestamp / dateDATETIME / DATE
uuidUUID
json / jsonbJSON
pgEnum / mysqlEnumENUM

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.