Skip to content

Commit 66ae12a

Browse files
committed
fix db pusher
1 parent 1be90f8 commit 66ae12a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/orm/src/client/helpers/schema-db-pusher.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
2323
await this.kysely.transaction().execute(async (tx) => {
2424
if (this.schema.enums && this.schema.provider.type === 'postgresql') {
2525
for (const [name, enumDef] of Object.entries(this.schema.enums)) {
26-
const createEnum = tx.schema.createType(name).asEnum(
27-
Object.values(enumDef.fields ?? {}).map((f) => {
26+
let enumValues: string[];
27+
if (enumDef.fields) {
28+
enumValues = Object.values(enumDef.fields).map((f) => {
2829
const mapAttr = f.attributes?.find((a) => a.name === '@map');
2930
if (!mapAttr || !mapAttr.args?.[0]) {
3031
return f.name;
@@ -36,8 +37,12 @@ export class SchemaDbPusher<Schema extends SchemaDef> {
3637
);
3738
return mappedName;
3839
}
39-
}),
40-
);
40+
});
41+
} else {
42+
enumValues = Object.values(enumDef.values);
43+
}
44+
45+
const createEnum = tx.schema.createType(name).asEnum(enumValues);
4146
await createEnum.execute();
4247
}
4348
}

tests/e2e/orm/query-builder/query-builder.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createId } from '@paralleldrive/cuid2';
2+
import { createTestClient } from '@zenstackhq/testtools';
23
import { describe, expect, it } from 'vitest';
34
import { getSchema } from '../schemas/basic';
4-
import { createTestClient } from '@zenstackhq/testtools';
55

66
describe('Client API tests', () => {
77
const schema = getSchema('sqlite');

0 commit comments

Comments
 (0)