import { PrismaClient } from '@prisma/client'; import * as dotenv from 'dotenv'; import * as path from 'path'; dotenv.config({ path: path.join(__dirname, '../../.env') }); const prisma = new PrismaClient(); async function main() { console.log('🚀 Starting modular flags migration...'); const orgs = await prisma.organization.findMany(); console.log(`Found ${orgs.length} organizations to update.`); for (const org of orgs) { const isCrmActive = org.useCase === 'CRM_WHATSAPP'; const isEdTechActive = org.useCase === 'EDUCATION'; await prisma.organization.update({ where: { id: org.id }, data: { isCrmActive, isEdTechActive } }); console.log(`✅ Updated Org: ${org.name} (CRM: ${isCrmActive}, EdTech: ${isEdTechActive})`); } console.log('✨ Migration completed successfully!'); } main() .catch((e) => { console.error('❌ Migration failed:', e); process.exit(1); }) .finally(async () => { await prisma.$disconnect(); });