@@ -2,6 +2,7 @@ import { drizzle as DrizzlePostgres } from "drizzle-orm/node-postgres";
22import { Pool } from "pg" ;
33import { readConfigFile } from "@server/lib/readConfigFile" ;
44import { withReplicas } from "drizzle-orm/pg-core" ;
5+ import * as schema from "./schema" ;
56
67function 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 : 5000 ,
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
6465export const db = createDb ( ) ;
0 commit comments