CognxSafeTrack
feat: implement bulk whatsapp campaigns with BullMQ and modular activation refactor (isCrmActive/isEdTechActive)
e286845 Download packages/database/src/migrate-flags.ts from safetrack/edtech: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/spaces/safetrack/edtech/resolve/main/packages/database/src/migrate-flags.ts
- Command line
-
hf download hf://spaces/safetrack/edtech/packages/database/src/migrate-flags.ts
-
curl -L -o migrate-flags.ts https://huggingface.co/spaces/safetrack/edtech/resolve/main/packages/database/src/migrate-flags.ts
1.1 kB
| 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(); | |
| }); | |