From 1f3d4f80eee150420896eaf9ef0b5f31f52d4d8a Mon Sep 17 00:00:00 2001 From: Sukairo-02 Date: Thu, 8 Aug 2024 21:05:48 +0300 Subject: [PATCH] Fixed lack of `sql` imports on `uuid` defaults --- package.json | 2 +- src/util/generators/mysql.ts | 2 ++ src/util/generators/pg.ts | 2 ++ src/util/generators/sqlite.ts | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 791eb10..a1ee9ca 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "drizzle-prisma-generator", "author": "Drizzle Team", - "version": "0.1.5", + "version": "0.1.6", "description": "Generate Drizzle schema from Prisma schema", "scripts": { "run": "pnpm run build && cd ../prisma-testbench && npx prisma generate dev && code ./src/db/schema.ts", diff --git a/src/util/generators/mysql.ts b/src/util/generators/mysql.ts index 375b659..b5a216b 100755 --- a/src/util/generators/mysql.ts +++ b/src/util/generators/mysql.ts @@ -90,6 +90,8 @@ const addColumnModifiers = (field: DMMF.Field, column: string) => { if (/^uuid\([0-9]*\)$/.test(value.name)) { column = column + `.default(sql\`uuid()\`)`; + + drizzleImports.add('sql'); break; } diff --git a/src/util/generators/pg.ts b/src/util/generators/pg.ts index e4c8498..1042fb7 100755 --- a/src/util/generators/pg.ts +++ b/src/util/generators/pg.ts @@ -91,6 +91,8 @@ const addColumnModifiers = (field: DMMF.Field, column: string) => { if (/^uuid\([0-9]*\)$/.test(value.name)) { column = column + `.default(sql\`uuid()\`)`; + + drizzleImports.add('sql'); break; } diff --git a/src/util/generators/sqlite.ts b/src/util/generators/sqlite.ts index b4f388e..0aeb2c8 100755 --- a/src/util/generators/sqlite.ts +++ b/src/util/generators/sqlite.ts @@ -84,6 +84,8 @@ const addColumnModifiers = (field: DMMF.Field, column: string) => { if (/^uuid\([0-9]*\)$/.test(value.name)) { column = column + `.default(sql\`uuid()\`)`; + + drizzleImports.add('sql'); break; }