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

async function updateEnum() {
    try {
        console.log('Attempting to update PostgreSQL ENUM: enum_resignations_currentStage...');
        
        // Note: ALTER TYPE ... ADD VALUE cannot be executed in a transaction block in some Postgres versions.
        // Sequelize's queryInterface.sequelize.query uses a transaction if not specified otherwise.
        
        await db.sequelize.query('ALTER TYPE "enum_resignations_currentStage" ADD VALUE IF NOT EXISTS \'RBM + DD-ZM Review\'');
        
        console.log('SUCCESS: ENUM updated successfully.');
        process.exit(0);
    } catch (error) {
        console.error('FAILED to update ENUM:', error.message);
        if (error.message.includes('already exists')) {
            console.log('INFO: Value already exists, proceeding.');
            process.exit(0);
        }
        process.exit(1);
    }
}

updateEnum();
