require('dotenv').config();
const { Client } = require('pg');

const client = new Client({
    host: process.env.DB_HOST,
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    port: process.env.DB_PORT,
});

(async () => {
    try {
        await client.connect();

        const tables = ['job', 'client'];

        for (const table of tables) {
            console.log(`\n--- Columns in table '${table}' ---`);
            const res = await client.query(`
                SELECT column_name, data_type 
                FROM information_schema.columns 
                WHERE table_name = '${table}'
                ORDER BY ordinal_position;
            `);
            res.rows.forEach(r => console.log(`${r.column_name} (${r.data_type})`));
        }

        await client.end();
    } catch (err) {
        console.error(err);
        process.exit(1);
    }
})();
