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

const updateEnum = async () => {
    try {
        console.log('>>> STARTING ENUM MIGRATION (Level 3) <<<');
        await db.sequelize.authenticate();
        console.log('Database connection established.');

        try {
            await db.sequelize.query(`ALTER TYPE "enum_applications_overallStatus" ADD VALUE IF NOT EXISTS 'Level 3 Approved';`);
            console.log('Added Level 3 Approved');
        } catch (e) {
            console.log('Level 3 Approved likely exists or error', e instanceof Error ? e.message : String(e));
        }

        console.log('>>> SUCCESS: Enum values updated <<<');

        await db.sequelize.close();
        process.exit(0);
    } catch (error) {
        console.error('>>> ERROR: Failed to update Enum', error);
        process.exit(1);
    }
};

updateEnum();
