CognxSafeTrack
feat: implement bulk whatsapp campaigns with BullMQ and modular activation refactor (isCrmActive/isEdTechActive)
e286845 | 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(); | |
| }); | |