Update database connection and storage for production

Adjusts database connection to use DATABASE_URL for production and switches to PostgreSQL storage when NODE_ENV is 'production'.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: a388004f-01c5-42b1-b1d1-f18daf8bdd0c
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/a388004f-01c5-42b1-b1d1-f18daf8bdd0c/h5q2Xzp
This commit is contained in:
michaelschal committed 2025-08-06 11:27:47 +00:00
1 parent a6b0719ebf
commit 5ee43c8357
3 files changed
+13 -13

No files matched your search

+1
View File
@@ -0,0 +1 @@
backup
+8 -11
View File
@@ -8,16 +8,13 @@ if (!process.env.DATABASE_URL) {
);
}
// Configuration de connexion avec support Unix socket pour PostgreSQL local
const connectionConfig = {
user: process.env.PGUSER,
password: process.env.PGPASSWORD,
database: process.env.PGDATABASE,
host: '/home/runner/postgres_data/socket',
port: 5432,
ssl: false // Désactiver SSL pour PostgreSQL local
};
export const pool = new Pool(connectionConfig);
// Configuration pour production avec DATABASE_URL
export const pool = new Pool({
connectionString: process.env.DATABASE_URL,
ssl: process.env.NODE_ENV === 'production' ? { rejectUnauthorized: false } : false,
max: 20, // Maximum number of clients in the pool
idleTimeoutMillis: 30000, // Close idle clients after 30 seconds
connectionTimeoutMillis: 2000, // Return an error after 2 seconds if connection cannot be established
});
export const db = drizzle(pool, { schema });
+4 -2
View File
@@ -679,5 +679,7 @@ class MemStorageWithBackup extends MemStorage {
}
}
// Use in-memory storage with backup functionality for now
export const storage = new MemStorageWithBackup();
// Use PostgreSQL storage in production, in-memory for development
export const storage = process.env.NODE_ENV === 'production'
? new DatabaseStorage()
: new MemStorageWithBackup();