Skip to content

Commit

Permalink
Fix tables not generating
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Mario564 committed Jul 20, 2024
1 parent af2dc04 commit 32e18bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -38,6 +38,6 @@
"vitest": "^0.34.3"
},
"dependencies": {
"drizzle-orm": "^0.31.1"
"drizzle-orm": "^0.32.0"
}
}
17 changes: 13 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions src/generators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
createOne,
getTableColumns,
is,
isTable,
Table,
Column
} from 'drizzle-orm';
Expand All @@ -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';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 32e18bc

Please sign in to comment.