import db from '../database/models/index.js';
const { User } = db;

async function patchUserStatus() {
    try {
        console.log('--- Starting User Status Patch ---');
        
        const [updatedCount] = await User.update(
            { status: 'inactive' },
            { 
                where: { 
                    status: 'deactivated' 
                } 
            }
        );

        console.log(`Success: Updated ${updatedCount} users from "deactivated" to "inactive".`);
        
        // Also check if any are 'Deactive' (case variant)
        const [updatedCount2] = await User.update(
            { status: 'inactive' },
            { 
                where: { 
                    status: 'deactive' 
                } 
            }
        );
        
        if (updatedCount2 > 0) {
            console.log(`Success: Updated ${updatedCount2} users from "deactive" to "inactive".`);
        }

        console.log('--- Patch Completed Successfully ---');
        process.exit(0);
    } catch (error) {
        console.error('Error during patch execution:', error);
        process.exit(1);
    }
}

patchUserStatus();
