Automatically generate Drizzle schema from Prisma schema
- Install generator:
pnpm add -D drizzle-prisma-generator - Add generator to prisma:
generator drizzle {
provider = "drizzle-prisma-generator"
output = "./src/schema.ts"
relationsVersion = "v1"
}.ts, it will be treated like a folder, and schema will be generated to schema.ts inside of it.
MySQL, PostgreSQL are not yet supported by drizzle-orm, therefore will throw an error.
postgresql, mysql, sqlite data providers, others will throw an error.
relationsVersion is v1. if relationsVersion is not provided, the relations file for rqbv2 is generated and saved inside the parent folder of schema.ts as relations.ts
snake_case, camelCase as casing while generating foreign key constraints, others will not do anything
:warning: - currently the supported value for version is v1. if version is not provided, the relations file for rqbv2 is generated and saved inside the parent folder of schema.ts as relations.ts
- Install
drizzle-orm:pnpm add drizzle-orm - Import schema from specified output file\folder
- Congratulations, now you can use Drizzle ORM with generated schemas!