const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function main() {
    console.log('Fixing invalid statuses...');
    try {
        const count = await prisma.$executeRaw`UPDATE client SET status = 'LEAD' WHERE status = '' OR status IS NULL`;
        console.log('Fixed client records:', count);
        
        const countOpp = await prisma.$executeRaw`UPDATE opportunity SET stage = 'LEAD' WHERE stage = '' OR stage IS NULL`;
        console.log('Fixed opportunity records:', countOpp);
    } catch (e) {
        console.error('Error fixing statuses:', e);
    } finally {
        await prisma.$disconnect();
    }
}

main();
