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
|
// Database connection configuration
|
||||||
export const pool = new Pool(config);
|
export const pool = new Pool(config);
|
||||||
|
|
||||||
// Set search_path after connection
|
// Set search_path on connection using pool 'connect' event
|
||||||
const originalConnect = pool.connect.bind(pool);
|
// This is safer than overriding pool.connect
|
||||||
pool.connect = async () => {
|
pool.on('connect', (client) => {
|
||||||
const client = await originalConnect();
|
|
||||||
const dbUrl = process.env.DATABASE_URL || '';
|
const dbUrl = process.env.DATABASE_URL || '';
|
||||||
if (dbUrl.includes('search_path=')) {
|
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
|
// Test database connection
|
||||||
export async function testConnection() {
|
export async function testConnection() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue