36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
// // prisma/mock-seeds-scripts/06-customers-archive.ts
|
|
// import { PrismaClient } from '@prisma/client';
|
|
|
|
// if (process.env.SKIP_LEAVE_REQUESTS === 'true') {
|
|
// console.log("⏭ Seed leave-requests ignoré (SKIP_LEAVE_REQUESTS=true)");
|
|
// process.exit(0);
|
|
// }
|
|
|
|
// const prisma = new PrismaClient();
|
|
|
|
// async function main() {
|
|
// const customers = await prisma.customers.findMany({
|
|
// orderBy: { id: 'asc' },
|
|
// take: 5,
|
|
// });
|
|
|
|
// for (const c of customers) {
|
|
// const invoiceId = 200000 + c.id; // déterministe, stable entre runs
|
|
|
|
// await prisma.customersArchive.upsert({
|
|
// where: { invoice_id: invoiceId }, // invoice_id est unique
|
|
// update: {}, // idempotent
|
|
// create: {
|
|
// customer_id: c.id,
|
|
// user_id: c.user_id,
|
|
// invoice_id: invoiceId,
|
|
// },
|
|
// });
|
|
// }
|
|
|
|
// const total = await prisma.customersArchive.count();
|
|
// console.log(`✓ CustomersArchive upserted for ${customers.length} customers (total=${total})`);
|
|
// }
|
|
|
|
// main().finally(() => prisma.$disconnect());
|