mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-12 01:37:40 +02:00
Fix database schema inspection on production servers
Update database connection logic in `routes.ts` to use the established `pool` for schema inspection queries, resolving issues with data retrieval on production environments. Replit-Commit-Author: Agent Replit-Commit-Session-Id: b163d4c0-de5e-4f4e-a9c0-aed4c7049718 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/b163d4c0-de5e-4f4e-a9c0-aed4c7049718/kdCs97W
This commit is contained in:
1 parent
461290a4f8
commit
d4878e6c8f
1 file changed
+10
-4
+10
-4
@@ -3,6 +3,7 @@ import { createServer, type Server } from "http";
|
||||
import { storage } from "./storage";
|
||||
import { setupLocalAuth, requireAuth } from "./localAuth";
|
||||
import { requireModulePermission, requireAdmin } from "./permissions";
|
||||
import { db, pool } from "./db";
|
||||
|
||||
console.log('🔍 Using development storage and authentication');
|
||||
|
||||
@@ -1405,6 +1406,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
console.log('\n🔍 ===== DÉBUT SCAN SCHÉMA BASE DE DONNÉES =====');
|
||||
console.log('⏰ Timestamp:', new Date().toISOString());
|
||||
|
||||
// Vérifier que pool est disponible
|
||||
if (!pool) {
|
||||
throw new Error('Pool de base de données non disponible en production');
|
||||
}
|
||||
|
||||
// Récupérer les tables
|
||||
const tablesQuery = `
|
||||
SELECT table_name
|
||||
@@ -1413,7 +1419,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
ORDER BY table_name
|
||||
`;
|
||||
|
||||
const tablesResult = await (storage as any).db.query(tablesQuery);
|
||||
const tablesResult = await pool.query(tablesQuery);
|
||||
|
||||
console.log(`\n📊 TOTAL DES TABLES TROUVÉES: ${tablesResult.rows.length}`);
|
||||
console.log('==========================================');
|
||||
@@ -1439,7 +1445,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
ORDER BY ordinal_position
|
||||
`;
|
||||
|
||||
const columnsResult = await (storage as any).db.query(columnsQuery, [tableName]);
|
||||
const columnsResult = await pool.query(columnsQuery, [tableName]);
|
||||
|
||||
if (columnsResult.rows.length > 0) {
|
||||
columnsResult.rows.forEach((col, index) => {
|
||||
@@ -1453,7 +1459,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Compter les enregistrements dans la table
|
||||
try {
|
||||
const countQuery = `SELECT COUNT(*) as total FROM "${tableName}"`;
|
||||
const countResult = await (storage as any).db.query(countQuery);
|
||||
const countResult = await pool.query(countQuery);
|
||||
console.log(` 📈 Nombre d'enregistrements: ${countResult.rows[0].total}`);
|
||||
} catch (countError) {
|
||||
console.log(` ⚠️ Impossible de compter les enregistrements: ${countError.message}`);
|
||||
@@ -1484,7 +1490,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
ORDER BY tc.table_name, kcu.column_name
|
||||
`;
|
||||
|
||||
const fkResult = await (storage as any).db.query(fkQuery);
|
||||
const fkResult = await pool.query(fkQuery);
|
||||
|
||||
if (fkResult.rows.length > 0) {
|
||||
fkResult.rows.forEach(fk => {
|
||||
|
||||
Reference in new issue
Block a user