edtech / packages /database /src /seed-multi-tenant.ts
CognxSafeTrack
feat: finalize multi-tenant WhatsApp architecture for Meta Tech Provider review
3bf9adc
import { PrismaClient } from '@prisma/client';
const DEFAULT_ORG_ID = 'default-org-id';
async function main() {
const prisma = new PrismaClient();
console.log('🚀 Starting Multi-Tenant Migration Seed...');
// 1. Create Default Organization
const org = await prisma.organization.upsert({
where: { id: DEFAULT_ORG_ID },
update: { name: 'XAMLÉ Global' },
create: {
id: DEFAULT_ORG_ID,
name: 'XAMLÉ Global',
},
});
console.log(`✅ Default Organization created: ${org.name} (${org.id})`);
// 2. Connect existing data (Prisma handles the @default value in the DB,
// but we ensure consistency here for relations if needed).
// Actually, since I set a default value in the schema,
// newly generated migrations will set this value for existing rows.
console.log('✨ Multi-Tenant Migration Seed completed.');
}
main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
const prisma = new PrismaClient();
await prisma.$disconnect();
});