fix: corrige deadlock no pool.connect do seeder
Usa pool.on('connect') em vez de override de pool.connect
This commit is contained in:
parent
11b40fe700
commit
69a5d779c6
1 changed files with 7 additions and 7 deletions
|
|
@ -55,16 +55,16 @@ console.log('🔌 DB Config:', {
|
|||
// Database connection configuration
|
||||
export const pool = new Pool(config);
|
||||
|
||||
// Set search_path after connection
|
||||
const originalConnect = pool.connect.bind(pool);
|
||||
pool.connect = async () => {
|
||||
const client = await originalConnect();
|
||||
// Set search_path on connection using pool 'connect' event
|
||||
// This is safer than overriding pool.connect
|
||||
pool.on('connect', (client) => {
|
||||
const dbUrl = process.env.DATABASE_URL || '';
|
||||
if (dbUrl.includes('search_path=')) {
|
||||
await client.query("SET search_path TO ghj");
|
||||
client.query("SET search_path TO ghj").catch(err => {
|
||||
console.error('Failed to set search_path:', err.message);
|
||||
});
|
||||
}
|
||||
return client;
|
||||
};
|
||||
});
|
||||
|
||||
// Test database connection
|
||||
export async function testConnection() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue