diff --git a/package.json b/package.json index 6c71410..7ab0111 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "drizzle-dbml-generator", - "version": "0.7.0", + "version": "0.8.0", "description": "Convert your Drizzle ORM schema into DBML markup", "main": "dist/index.cjs", "module": "dist/index.js", @@ -38,6 +38,6 @@ "vitest": "^0.34.3" }, "dependencies": { - "drizzle-orm": "^0.31.1" + "drizzle-orm": "^0.32.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7206b01..93f439f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,8 +6,8 @@ settings: dependencies: drizzle-orm: - specifier: ^0.31.1 - version: 0.31.1 + specifier: ^0.32.0 + version: 0.32.0 devDependencies: '@types/node': @@ -777,8 +777,8 @@ packages: esutils: 2.0.3 dev: true - /drizzle-orm@0.31.1: - resolution: {integrity: sha512-hTbYne2XX3y6sV7WSxcPH6/vNSiQSUG9VZsFI27jBMCN0OT3Ok7ao3pIT5OMAqWkzJCRFgGjAaUeTAZWPgOKag==} + /drizzle-orm@0.32.0: + resolution: {integrity: sha512-99IlfVGPNHzOFEXo9Phyu5At5TALLsY2t6WxFFy68rYd9Ej4cHX/7WjdPOn7JNRW69MNeNtP8XrDQg43SppuAA==} peerDependencies: '@aws-sdk/client-rds-data': '>=3' '@cloudflare/workers-types': '>=3' @@ -788,6 +788,8 @@ packages: '@op-engineering/op-sqlite': '>=2' '@opentelemetry/api': ^1.4.1 '@planetscale/database': '>=1' + '@prisma/client': '*' + '@tidbcloud/serverless': '*' '@types/better-sqlite3': '*' '@types/pg': '*' '@types/react': '>=18' @@ -802,6 +804,7 @@ packages: mysql2: '>=2' pg: '>=8' postgres: '>=3' + prisma: '*' react: '>=18' sql.js: '>=1' sqlite3: '>=5' @@ -822,6 +825,10 @@ packages: optional: true '@planetscale/database': optional: true + '@prisma/client': + optional: true + '@tidbcloud/serverless': + optional: true '@types/better-sqlite3': optional: true '@types/pg': @@ -850,6 +857,8 @@ packages: optional: true postgres: optional: true + prisma: + optional: true react: optional: true sql.js: diff --git a/src/generators/common.ts b/src/generators/common.ts index 2f5f01f..fee92fa 100644 --- a/src/generators/common.ts +++ b/src/generators/common.ts @@ -8,7 +8,6 @@ import { createOne, getTableColumns, is, - isTable, Table, Column } from 'drizzle-orm'; @@ -25,18 +24,21 @@ import { PgEnum, PrimaryKey as PgPrimaryKey, UniqueConstraint as PgUniqueConstraint, - isPgEnum + isPgEnum, + PgTable } from 'drizzle-orm/pg-core'; import { ForeignKey as MySqlForeignKey, Index as MySqlIndex, PrimaryKey as MySqlPrimaryKey, + MySqlTable, UniqueConstraint as MySqlUniqueConstraint } from 'drizzle-orm/mysql-core'; import { ForeignKey as SQLiteForeignKey, Index as SQLiteIndex, PrimaryKey as SQLitePrimaryKey, + SQLiteTable, UniqueConstraint as SQLiteUniqueConstraint } from 'drizzle-orm/sqlite-core'; import { writeFileSync } from 'fs'; @@ -175,7 +177,7 @@ export abstract class BaseGenerator< if (is(index, PgIndex) || is(index, MySqlIndex) || is(index, SQLiteIndex)) { const configColumns = index.config.columns.flatMap((entry) => - is(entry, SQL) ? entry.queryChunks.filter((v) => is(v, Column)) : entry + is(entry, SQL) ? entry.queryChunks.filter((v) => is(v, Column)) : (entry as Column) ); const idxColumns = wrapColumns( @@ -323,7 +325,7 @@ export abstract class BaseGenerator< if (isPgEnum(value)) { generatedEnums.push(this.generateEnum(value)); - } else if (isTable(value)) { + } else if (is(value, PgTable) || is(value, MySqlTable) || is(value, SQLiteTable)) { generatedTables.push(this.generateTable(value as unknown as AnyTable)); } else if (is(value, Relations)) { relations.push(value);