edtech / packages /database /src /migrate-flags.ts
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();
});