Skip to content

Commit 485013f

Browse files
committed
Build fix
1 parent 4975d59 commit 485013f

File tree

6 files changed

+20
-17
lines changed

6 files changed

+20
-17
lines changed

drizzle-kit/src/ext/api-postgres.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { PGlite } from '@electric-sql/pglite';
22
import type { Relations } from 'drizzle-orm/_relations';
3-
import type { AnyPgTable, PgDatabase } from 'drizzle-orm/pg-core';
3+
import type { AnyPgTable } from 'drizzle-orm/pg-core';
4+
import type { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
45
import type { EntitiesFilterConfig } from 'src/cli/validations/cli';
56
import { upToV8 } from 'src/dialects/postgres/versions';
67
import type { CasingType } from '../cli/validations/common';
@@ -110,7 +111,7 @@ export const generateMigration = async (
110111

111112
export const pushSchema = async (
112113
imports: Record<string, unknown>,
113-
drizzleInstance: PgDatabase<any>,
114+
drizzleInstance: PgAsyncDatabase<any>,
114115
casing?: CasingType,
115116
entitiesConfig?: EntitiesFilterConfig,
116117
) => {

drizzle-seed/src/SeedService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { entityKind, eq, is, sql } from 'drizzle-orm';
33
import type { MySqlTable, MySqlTableWithColumns } from 'drizzle-orm/mysql-core';
44
import { MySqlDatabase } from 'drizzle-orm/mysql-core';
55
import type { PgTable, PgTableWithColumns } from 'drizzle-orm/pg-core';
6-
import { PgDatabase } from 'drizzle-orm/pg-core';
6+
import { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
77
import type { SQLiteTable, SQLiteTableWithColumns } from 'drizzle-orm/sqlite-core';
88
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
99
import { generatorsMap } from './generators/GeneratorFuncs.ts';
@@ -919,7 +919,7 @@ export class SeedService {
919919
// }
920920
}
921921
let maxParametersNumber: number;
922-
if (is(db, PgDatabase<any>)) {
922+
if (is(db, PgAsyncDatabase<any>)) {
923923
// @ts-ignore
924924
maxParametersNumber = db.constructor[entityKind] === 'PgliteDatabase'
925925
? this.postgresPgLiteMaxParametersNumber
@@ -1040,7 +1040,7 @@ export class SeedService {
10401040
tableName: string;
10411041
override: boolean;
10421042
}) => {
1043-
if (is(db, PgDatabase<any>)) {
1043+
if (is(db, PgAsyncDatabase<any>)) {
10441044
const query = db.insert((schema as { [key: string]: PgTable })[tableName]!);
10451045
if (override === true) {
10461046
return await query.overridingSystemValue().values(generatedValues);
@@ -1105,7 +1105,7 @@ export class SeedService {
11051105
const uniqueNotNullColValue = values[uniqueNotNullColName];
11061106
values = Object.fromEntries(Object.entries(values).filter(([colName]) => colName !== uniqueNotNullColName));
11071107

1108-
if (is(db, PgDatabase<any>)) {
1108+
if (is(db, PgAsyncDatabase<any>)) {
11091109
const table = (schema as { [key: string]: PgTableWithColumns<any> })[tableName]!;
11101110
const uniqueNotNullCol = table[uniqueNotNullColName];
11111111
await db.update(table).set(values).where(

drizzle-seed/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { MySqlColumn, MySqlSchema, MySqlTable } from 'drizzle-orm/mysql-cor
66
import { MySqlDatabase } from 'drizzle-orm/mysql-core';
77

88
import type { PgColumn, PgSchema, PgTable } from 'drizzle-orm/pg-core';
9-
import { PgDatabase } from 'drizzle-orm/pg-core';
9+
import { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
1010

1111
import type { SQLiteColumn, SQLiteTable } from 'drizzle-orm/sqlite-core';
1212
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
@@ -81,7 +81,7 @@ export type InferCallbackType<
8181
SCHEMA extends {
8282
[key: string]: SchemaValuesType;
8383
},
84-
> = DB extends PgDatabase<any, any> ? RefineTypes<SCHEMA, PgTable, PgColumn>
84+
> = DB extends PgAsyncDatabase<any, any> ? RefineTypes<SCHEMA, PgTable, PgColumn>
8585
: DB extends MySqlDatabase<any, any> ? RefineTypes<SCHEMA, MySqlTable, MySqlColumn>
8686
: DB extends BaseSQLiteDatabase<any, any> ? RefineTypes<SCHEMA, SQLiteTable, SQLiteColumn>
8787
: DB extends MsSqlDatabase<any, any> ? RefineTypes<SCHEMA, MsSqlTable, MsSqlColumn>
@@ -326,7 +326,7 @@ const seedFunc = async (
326326
version = Number(options?.version);
327327
}
328328

329-
if (is(db, PgDatabase<any, any>)) {
329+
if (is(db, PgAsyncDatabase<any, any>)) {
330330
await seedPostgres(db, schema, { ...options, version }, refinements);
331331
} else if (is(db, MySqlDatabase<any, any>)) {
332332
await seedMySql(db, schema, { ...options, version }, refinements);
@@ -393,7 +393,7 @@ export async function reset<
393393
[key: string]: SchemaValuesType;
394394
},
395395
>(db: DB, schema: SCHEMA) {
396-
if (is(db, PgDatabase<any, any>)) {
396+
if (is(db, PgAsyncDatabase<any, any>)) {
397397
const { pgTables } = filterPgSchema(schema);
398398

399399
if (Object.entries(pgTables).length > 0) {

drizzle-seed/src/pg-core/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { is, sql } from 'drizzle-orm';
22
import { Relations } from 'drizzle-orm/_relations';
3-
import type { PgArray, PgDatabase, PgSchema } from 'drizzle-orm/pg-core';
3+
import type { PgArray, PgSchema } from 'drizzle-orm/pg-core';
44
import { getTableConfig, PgTable } from 'drizzle-orm/pg-core';
5+
import type { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
56
import { getSchemaInfo } from '../common.ts';
67
import { SeedService } from '../SeedService.ts';
78
import type { RefinementsType } from '../types/seedService.ts';
89
import type { Column, TableConfigT } from '../types/tables.ts';
910

1011
// Postgres-----------------------------------------------------------------------------------------------------------
1112
export const resetPostgres = async (
12-
db: PgDatabase<any, any>,
13+
db: PgAsyncDatabase<any, any>,
1314
pgTables: { [key: string]: PgTable },
1415
) => {
1516
const tablesToTruncate = Object.entries(pgTables).map(([_, table]) => {
@@ -43,7 +44,7 @@ export const filterPgSchema = (schema: {
4344
};
4445

4546
export const seedPostgres = async (
46-
db: PgDatabase<any, any>,
47+
db: PgAsyncDatabase<any, any>,
4748
schema: {
4849
[key: string]:
4950
| PgTable

drizzle-seed/src/types/seedService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { CockroachDatabase, CockroachTable } from 'drizzle-orm/cockroach-core';
22
import type { MsSqlDatabase, MsSqlTable } from 'drizzle-orm/mssql-core';
33
import type { MySqlDatabase, MySqlTable } from 'drizzle-orm/mysql-core';
4-
import type { PgDatabase, PgTable } from 'drizzle-orm/pg-core';
4+
import type { PgTable } from 'drizzle-orm/pg-core';
5+
import type { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
56
import type { SingleStoreDatabase, SingleStoreTable } from 'drizzle-orm/singlestore-core';
67
import type { BaseSQLiteDatabase, SQLiteTable } from 'drizzle-orm/sqlite-core';
78
import type { AbstractGenerator } from '../generators/Generators.ts';
@@ -10,7 +11,7 @@ import type { Prettify } from './tables.ts';
1011
export type GeneratedValueType = number | bigint | string | Buffer | boolean | undefined;
1112

1213
export type DbType =
13-
| PgDatabase<any, any, any>
14+
| PgAsyncDatabase<any, any, any>
1415
| MySqlDatabase<any, any, any, any>
1516
| BaseSQLiteDatabase<any, any, any, any>
1617
| MsSqlDatabase<any, any, any, any>

drizzle-seed/tests/pg/instrumentation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { drizzle } from 'drizzle-orm/node-postgres';
2-
import type { PgDatabase } from 'drizzle-orm/pg-core';
2+
import type { PgAsyncDatabase } from 'drizzle-orm/pg-core/async';
33
import { Client } from 'pg';
44
import { test as base } from 'vitest';
55

@@ -27,7 +27,7 @@ const prepareTest = () => {
2727
query: (sql: string, params: any[]) => Promise<any[]>;
2828
batch: (statements: string[]) => Promise<void>;
2929
};
30-
db: PgDatabase<any, any, any>;
30+
db: PgAsyncDatabase<any, any, any>;
3131
push: (schema: any) => Promise<void>;
3232
}
3333
>({

0 commit comments

Comments
 (0)