import { Pool } from 'pg'; async function getColumns(pool: Pool, table: string) { const result = await pool.query( `SELECT column_name, data_type FROM information_schema.columns WHERE table_name = $1 ORDER BY ordinal_position`, [table] ); return result.rows; } async function run() { const nas = new Pool({ connectionString: 'postgresql://postgres:postgres@192.168.0.145:5434/nearestmass' }); const neon = new Pool({ connectionString: 'postgresql://neondb_owner:npg_sX8dxFg9KZIR@ep-plain-sky-ah15xa97-pooler.c-3.us-east-1.aws.neon.tech/neondb?sslmode=require', ssl: { rejectUnauthorized: false }, }); for (const table of ['churches', 'mass_schedules', 'confession_schedules', 'adoration_schedules']) { const nasCols = await getColumns(nas, table); const neonCols = await getColumns(neon, table); const nasNames = new Set(nasCols.map((c) => c.column_name)); const neonNames = new Set(neonCols.map((c) => c.column_name)); const onlyNas = nasCols.filter((c) => !neonNames.has(c.column_name)); const onlyNeon = neonCols.filter((c) => !nasNames.has(c.column_name)); if (onlyNas.length > 0 || onlyNeon.length > 0) { console.log(`\n=== ${table} ===`); if (onlyNas.length) { console.log(' NAS only:'); for (const c of onlyNas) console.log(` - ${c.column_name} (${c.data_type})`); } if (onlyNeon.length) { console.log(' Neon only:'); for (const c of onlyNeon) console.log(` - ${c.column_name} (${c.data_type})`); } } else { console.log(`\n=== ${table} === (schemas match)`); } } await nas.end(); await neon.end(); } run();