import { pgQuery, getPgPool } from '../lib/postgres/client';

async function checkTables() {
  const tables = [
    'recurring_schedule_jobs',
    'background_job_logs',
    'recurring_generation_duplicates',
    'escalation_executions',
    'scheduler_status'
  ];

  for (const table of tables) {
    console.log('--- Structure for ' + table + ' ---');
    try {
      const res = await pgQuery('SELECT column_name, data_type FROM information_schema.columns WHERE table_name = \'' + table + '\' ORDER BY ordinal_position;');
      if (res.rows.length === 0) {
        console.log('Table ' + table + ' NOT FOUND or has no columns.');
      } else {
        res.rows.forEach((row: any) => {
          console.log(row.column_name + ': ' + row.data_type);
        });
      }
    } catch (err: any) {
      console.error('Error checking ' + table + ':', err.message);
    }
    console.log('');
  }
}

checkTables()
  .then(() => getPgPool().end())
  .catch(console.error);
