@@ -2,6 +2,7 @@ import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
2
2
import { Pool } from "pg" ;
3
3
import { readConfigFile } from "@server/lib/readConfigFile" ;
4
4
import { withReplicas } from "drizzle-orm/pg-core" ;
5
+ import * as schema from "./schema" ;
5
6
6
7
function createDb ( ) {
7
8
const config = readConfigFile ( ) ;
@@ -45,7 +46,7 @@ function createDb() {
45
46
const replicas = [ ] ;
46
47
47
48
if ( ! replicaConnections . length ) {
48
- replicas . push ( DrizzlePostgres ( primaryPool ) ) ;
49
+ replicas . push ( DrizzlePostgres ( primaryPool , { schema } ) ) ;
49
50
} else {
50
51
for ( const conn of replicaConnections ) {
51
52
const replicaPool = new Pool ( {
@@ -54,11 +55,11 @@ function createDb() {
54
55
idleTimeoutMillis : 30000 ,
55
56
connectionTimeoutMillis : 2000 ,
56
57
} ) ;
57
- replicas . push ( DrizzlePostgres ( replicaPool ) ) ;
58
+ replicas . push ( DrizzlePostgres ( replicaPool , { schema } ) ) ;
58
59
}
59
60
}
60
61
61
- return withReplicas ( DrizzlePostgres ( primaryPool ) , replicas as any ) ;
62
+ return withReplicas ( DrizzlePostgres ( primaryPool , { schema } ) , replicas as any ) ;
62
63
}
63
64
64
65
export const db = createDb ( ) ;
0 commit comments