fix(seeds): added job_titles to employees and employees_archive

This commit is contained in:
Matthieu Haineault 2025-08-13 15:34:50 -04:00
parent 24779b67f6
commit 3307f3c334
4 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "public"."employees" ADD COLUMN "job_title" TEXT;
-- AlterTable
ALTER TABLE "public"."employees_archive" ADD COLUMN "job_title" TEXT;

View File

@ -16,6 +16,22 @@ function randomPastDate(yearsBack = 3) {
return d;
}
const jobTitles = [
'Directeur des ventes',
'Directeur technique',
'Programmeur',
'Technicien',
'Comptable',
'Magasinier',
'Responsable Resources Humaines',
'Conseiller en vente',
'Support technique',
];
function randomTitle() {
return jobTitles[randInt(0, jobTitles.length -1)];
}
async function main() {
const employeeUsers = await prisma.users.findMany({
where: { role: { in: [Roles.ADMIN, Roles.SUPERVISOR, Roles.HR, Roles.ACCOUNTING, Roles.EMPLOYEE] } },
@ -36,6 +52,7 @@ async function main() {
company_code: randInt(1, 5),
first_work_day: randomPastDate(3),
last_work_day: null,
job_title: randomTitle(),
},
});
supervisorEmployeeIds.push(emp.id);
@ -57,6 +74,7 @@ async function main() {
first_work_day: randomPastDate(3),
last_work_day: null,
supervisor_id,
job_title: randomTitle(),
},
});
}

View File

@ -27,6 +27,7 @@ async function main() {
first_Work_Day: e.first_work_day,
last_work_day: daysAgo(30),
supervisor_id: e.supervisor_id ?? null,
job_title: e.job_title,
},
});
}

View File

@ -40,7 +40,7 @@ model Employees {
company_code Int
first_work_day DateTime @db.Date
last_work_day DateTime? @db.Date
job_title String
job_title String?
supervisor Employees? @relation("EmployeeSupervisor", fields: [supervisor_id], references: [id])
supervisor_id Int?
@ -64,7 +64,7 @@ model EmployeesArchive {
user Users @relation("UsersToEmployeesToArchive", fields: [user_id], references: [id])
first_name String
last_name String
job_title String
job_title String?
external_payroll_id Int
company_code Int