Skip to content

Commit 7c11079

Browse files
add schema to pg driver
1 parent fcee988 commit 7c11079

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

server/db/pg/driver.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
22
import { Pool } from "pg";
33
import { readConfigFile } from "@server/lib/readConfigFile";
44
import { withReplicas } from "drizzle-orm/pg-core";
5+
import * as schema from "./schema";
56

67
function createDb() {
78
const config = readConfigFile();
@@ -45,7 +46,7 @@ function createDb() {
4546
const replicas = [];
4647

4748
if (!replicaConnections.length) {
48-
replicas.push(DrizzlePostgres(primaryPool));
49+
replicas.push(DrizzlePostgres(primaryPool, { schema }));
4950
} else {
5051
for (const conn of replicaConnections) {
5152
const replicaPool = new Pool({
@@ -54,11 +55,11 @@ function createDb() {
5455
idleTimeoutMillis: 30000,
5556
connectionTimeoutMillis: 2000,
5657
});
57-
replicas.push(DrizzlePostgres(replicaPool));
58+
replicas.push(DrizzlePostgres(replicaPool, { schema }));
5859
}
5960
}
6061

61-
return withReplicas(DrizzlePostgres(primaryPool), replicas as any);
62+
return withReplicas(DrizzlePostgres(primaryPool, { schema }), replicas as any);
6263
}
6364

6465
export const db = createDb();

0 commit comments

Comments
 (0)