28 lines
747 B
TypeScript
28 lines
747 B
TypeScript
import { PrismaClient, Prisma } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const employees = await prisma.employees.findMany({ select: { id: true } });
|
|
|
|
// ✅ typer rows pour éviter never[]
|
|
const rows: Prisma.TimesheetsCreateManyInput[] = [];
|
|
|
|
// 8 timesheets / employee
|
|
for (const e of employees) {
|
|
for (let i = 0; i < 8; i++) {
|
|
const is_approved = Math.random() < 0.3;
|
|
rows.push({ employee_id: e.id, is_approved });
|
|
}
|
|
}
|
|
|
|
if (rows.length) {
|
|
await prisma.timesheets.createMany({ data: rows });
|
|
}
|
|
|
|
const total = await prisma.timesheets.count();
|
|
console.log(`✓ Timesheets: ${total} rows (added ${rows.length})`);
|
|
}
|
|
|
|
main().finally(() => prisma.$disconnect());
|