Registry / database / drizzle-prisma-generator

drizzle-prisma-generator

JSON →
library0.1.7jsnpmunverified

Automatically generate Drizzle ORM schema files from an existing Prisma schema. Current stable version is 0.1.7. This tool bridges Prisma and Drizzle ORM ecosystems, allowing developers to use Prisma's schema design capabilities while leveraging Drizzle's lightweight, type-safe query builder. Unlike alternative approaches that require manual schema rewriting, this generator produces a fully typed Drizzle schema that mirrors the Prisma model definitions. Supports PostgreSQL, MySQL, and SQLite data providers; binary types are not yet supported. Output can be a single TypeScript file or a folder. Works with both ESM and CJS projects. Released by the Drizzle team with active maintenance.

npm install drizzle-prisma-generator
INSTALL
IMPORT
SIG · DRIZZLE-PRISMA-GEN
D
drizzle-prisma-generator
databasejavascriptv0.1.7
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.

* as schema
import * as schema from './src/schema'
import schema from './src/schema'
The generated file uses named exports for each table/model, so you must use a namespace import.
drizzle
import { drizzle } from 'drizzle-orm/postgres-js'
import { drizzle } from 'drizzle-orm'
Drizzle ORM requires a driver-specific import; replace 'postgres-js' with your chosen driver (e.g., 'mysql2', 'better-sqlite3').
eq
import { eq } from 'drizzle-orm'
Operators like eq, and, or are imported from 'drizzle-orm'. No common mistake.

Install the generator, configure in Prisma schema, generate the Drizzle schema, then use it with Drizzle ORM and a driver.

// 1. Install generator and drizzle-orm // pnpm add -D drizzle-prisma-generator drizzle-orm // 2. Add to prisma/schema.prisma: // generator drizzle { // provider = "drizzle-prisma-generator" // output = "./src/db/schema.ts" // } // 3. Run prisma generate: npx prisma generate // 4. In your application: import * as schema from './src/db/schema'; import { drizzle } from 'drizzle-orm/postgres-js'; import postgres from 'postgres'; const client = postgres(process.env.DATABASE_URL ?? ''); const db = drizzle(client, { schema }); // 5. Query using generated schema const users = await db.select().from(schema.users).where(eq(schema.users.id, 1));
Debug
Known issues
gotchaBinary types (e.g., MySQL BIT, PostgreSQL BYTEA) are not supported by drizzle-orm and will throw an error during generation.
fix
Remove or replace binary type fields from your Prisma schema before generation.
affects: >=0.1.0
gotchaOnly 'postgresql', 'mysql', and 'sqlite' data providers are supported. Using any other provider (e.g., 'mongodb', 'cockroachdb') will throw an error.
fix
Switch to a supported provider or do not use this generator.
affects: >=0.1.0
gotchaIf the 'output' path does not end with '.ts', it will be treated as a folder and the schema will be generated inside it as 'schema.ts'.
fix
Ensure output ends with '.ts' to generate a single file at that exact path.
affects: >=0.1.0
deprecatedThe generator does not support Prisma v5 yet; only Prisma v4 is supported.
fix
Use Prisma v4 until the generator is updated to support v5.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Unknown provider "drizzle-prisma-generator"
Generator provider name is incorrect or package not installed.
fix
Ensure 'drizzle-prisma-generator' is installed (pnpm add -D drizzle-prisma-generator) and provider is exactly "drizzle-prisma-generator".
Error: Unsupported data provider: mongodb
Only PostgreSQL, MySQL, and SQLite are supported.
fix
Change your datasource provider in schema.prisma to 'postgresql', 'mysql', or 'sqlite'.
Error: Drizzle ORM does not support binary types
Binary type fields like BIT or BYTEA are not yet supported by drizzle-orm.
fix
Remove binary type fields or convert them to supported types (e.g., String).
Upgrade
Version history
0.1.7latest on npm
Audit
Dependencies
drizzle-ormrequiredRequired runtime dependency for the generated Drizzle schema to work.
Agent activity
11 hits · last 30 days
node
10
Resources
drizzle-prisma-generator — npm install drizzle-prisma-generator · libregistry