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

async function main() {
    console.log('Fetching distinct statuses...');
    try {
        const statuses = await prisma.client.groupBy({
            by: ['status'],
        });
        console.log('Current statuses in DB:', statuses);
        
        // Update invalid statuses
        // If status is empty string or 'CUSTOMER', change to 'SALES' or 'LEAD'
        const results = await prisma.client.updateMany({
            where: { status: '' },
            data: { status: 'LEAD' }
        });
        console.log('Updated empty statuses:', results.count);

    } catch (e) {
        console.error(e);
    } finally {
        await prisma.$disconnect();
    }
}

main();
