import pkg from 'pg'; const { Pool } = pkg; const devPool = new Pool({ host: '51.75.24.29', port: 5433, user: 'postgres', password: 'postgres', database: 'thetiptop_dev' }); const preprodPool = new Pool({ host: '51.75.24.29', port: 5434, user: 'postgres', password: 'postgres', database: 'thetiptop_preprod' }); const tables = ['users', 'prizes', 'tickets', 'game_settings', 'newsletters', 'email_templates', 'email_campaigns', 'email_campaign_recipients', 'grand_prize_draws']; console.log('=== COMPARAISON DES COLONNES DEV vs PREPROD ===\n'); const missingColumns = []; for (const table of tables) { const devCols = await devPool.query( "SELECT column_name FROM information_schema.columns WHERE table_name = $1 ORDER BY ordinal_position", [table] ); const preprodCols = await preprodPool.query( "SELECT column_name FROM information_schema.columns WHERE table_name = $1 ORDER BY ordinal_position", [table] ); const devSet = new Set(devCols.rows.map(r => r.column_name)); const preprodSet = new Set(preprodCols.rows.map(r => r.column_name)); const missingInPreprod = [...devSet].filter(c => !preprodSet.has(c)); const extraInPreprod = [...preprodSet].filter(c => !devSet.has(c)); if (missingInPreprod.length > 0 || extraInPreprod.length > 0) { console.log('❌ ' + table.toUpperCase()); if (missingInPreprod.length > 0) { console.log(' Manquantes en preprod: ' + missingInPreprod.join(', ')); missingColumns.push({ table, columns: missingInPreprod }); } if (extraInPreprod.length > 0) { console.log(' En plus en preprod: ' + extraInPreprod.join(', ')); } console.log(''); } else { console.log('✅ ' + table.toUpperCase() + ' - OK'); } } console.log('\n=== RÉSUMÉ ==='); if (missingColumns.length === 0) { console.log('✅ Toutes les colonnes sont synchronisées !'); } else { console.log('❌ Colonnes manquantes à ajouter en preprod:'); for (const m of missingColumns) { console.log(' - ' + m.table + ': ' + m.columns.join(', ')); } } await devPool.end(); await preprodPool.end(); process.exit(0);