import db from '../src/database/models/index.js';

async function cleanup() {
    try {
        await db.sequelize.authenticate();
        console.log('Database connected.');

        const [results1]: any = await db.sequelize.query(`
            DELETE FROM interview_participants 
            WHERE "interviewId" NOT IN (SELECT id FROM interviews)
        `);

        const [results2]: any = await db.sequelize.query(`
            DELETE FROM interview_evaluations 
            WHERE "interviewId" NOT IN (SELECT id FROM interviews)
        `);

        console.log('Cleanup finished.');
        process.exit(0);
    } catch (err) {
        console.error('Cleanup failed:', err);
        process.exit(1);
    }
}

cleanup();
