Skip to content

Commit 8935461

Browse files
add schema to pg driver
1 parent 2422c4f commit 8935461

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();
@@ -46,7 +47,7 @@ function createDb() {
4647
const replicas = [];
4748

4849
if (!replicaConnections.length) {
49-
replicas.push(DrizzlePostgres(primaryPool));
50+
replicas.push(DrizzlePostgres(primaryPool, { schema }));
5051
} else {
5152
for (const conn of replicaConnections) {
5253
const replicaPool = new Pool({
@@ -55,11 +56,11 @@ function createDb() {
5556
idleTimeoutMillis: poolConfig?.idle_timeout_ms || 30000,
5657
connectionTimeoutMillis: poolConfig?.connection_timeout_ms || 5000,
5758
});
58-
replicas.push(DrizzlePostgres(replicaPool));
59+
replicas.push(DrizzlePostgres(replicaPool, { schema }));
5960
}
6061
}
6162

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

6566
export const db = createDb();

0 commit comments

Comments
 (0)