fix(infra): pass PostgreSQL config to Prisma adapter

This commit is contained in:
2026-08-08 16:15:56 +00:00
parent cfc17bdb0b
commit fa66fb4b49
+8 -10
View File
@@ -1,5 +1,4 @@
import { PrismaPg } from '@prisma/adapter-pg'; import { PrismaPg } from '@prisma/adapter-pg';
import { Pool } from 'pg';
export type PostgresLogLevel = 'query' | 'info' | 'warn' | 'error'; export type PostgresLogLevel = 'query' | 'info' | 'warn' | 'error';
@@ -89,11 +88,13 @@ export const createPostgresConnector = <TClient>(
): PostgresConnector<TClient> => { ): PostgresConnector<TClient> => {
const schema = const schema =
extractSchemaFromDatabaseUrl(config.url) ?? process.env.POSTGRES_SCHEMA ?? process.env.DATABASE_SCHEMA; extractSchemaFromDatabaseUrl(config.url) ?? process.env.POSTGRES_SCHEMA ?? process.env.DATABASE_SCHEMA;
const pool = new Pool({ const adapter = new PrismaPg(
connectionString: config.url, {
...(schema ? { options: `-c search_path=${schema}` } : {}), connectionString: config.url,
}); ...(schema ? { options: `-c search_path=${schema}` } : {}),
const adapter = new PrismaPg(pool, schema ? { schema } : undefined); },
schema ? { schema } : undefined
);
const prisma = createClient({ const prisma = createClient({
adapter, adapter,
log: config.log, log: config.log,
@@ -102,9 +103,6 @@ export const createPostgresConnector = <TClient>(
return { return {
prisma, prisma,
connect: () => (prisma as { $connect: () => Promise<void> }).$connect(), connect: () => (prisma as { $connect: () => Promise<void> }).$connect(),
disconnect: async () => { disconnect: () => (prisma as { $disconnect: () => Promise<void> }).$disconnect(),
await (prisma as { $disconnect: () => Promise<void> }).$disconnect();
await pool.end();
},
}; };
}; };