mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-20 13:38:15 +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 { storage } from "./storage";
|
||||||
import { setupLocalAuth, requireAuth } from "./localAuth";
|
import { setupLocalAuth, requireAuth } from "./localAuth";
|
||||||
import { requireModulePermission, requireAdmin } from "./permissions";
|
import { requireModulePermission, requireAdmin } from "./permissions";
|
||||||
|
import { db, pool } from "./db";
|
||||||
|
|
||||||
console.log('🔍 Using development storage and authentication');
|
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('\n🔍 ===== DÉBUT SCAN SCHÉMA BASE DE DONNÉES =====');
|
||||||
console.log('⏰ Timestamp:', new Date().toISOString());
|
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
|
// Récupérer les tables
|
||||||
const tablesQuery = `
|
const tablesQuery = `
|
||||||
SELECT table_name
|
SELECT table_name
|
||||||
@@ -1413,7 +1419,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
ORDER BY table_name
|
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(`\n📊 TOTAL DES TABLES TROUVÉES: ${tablesResult.rows.length}`);
|
||||||
console.log('==========================================');
|
console.log('==========================================');
|
||||||
@@ -1439,7 +1445,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
ORDER BY ordinal_position
|
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) {
|
if (columnsResult.rows.length > 0) {
|
||||||
columnsResult.rows.forEach((col, index) => {
|
columnsResult.rows.forEach((col, index) => {
|
||||||
@@ -1453,7 +1459,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
|||||||
// Compter les enregistrements dans la table
|
// Compter les enregistrements dans la table
|
||||||
try {
|
try {
|
||||||
const countQuery = `SELECT COUNT(*) as total FROM "${tableName}"`;
|
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}`);
|
console.log(` 📈 Nombre d'enregistrements: ${countResult.rows[0].total}`);
|
||||||
} catch (countError) {
|
} catch (countError) {
|
||||||
console.log(` ⚠️ Impossible de compter les enregistrements: ${countError.message}`);
|
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
|
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) {
|
if (fkResult.rows.length > 0) {
|
||||||
fkResult.rows.forEach(fk => {
|
fkResult.rows.forEach(fk => {
|
||||||
|
|||||||
Reference in new issue
Block a user