R45 A2-A7 员工附件与培训证书管理
这个提交包含在:
@@ -0,0 +1,59 @@
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EmployeeTrainingType" AS ENUM ('internal', 'external', 'online');
|
||||
|
||||
-- CreateEnum
|
||||
CREATE TYPE "EmployeeTrainingStatus" AS ENUM ('planned', 'in_progress', 'completed', 'cancelled');
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "employee_trainings" (
|
||||
"id" UUID NOT NULL,
|
||||
"employee_id" UUID NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"training_type" "EmployeeTrainingType" NOT NULL,
|
||||
"start_date" DATE NOT NULL,
|
||||
"end_date" DATE,
|
||||
"status" "EmployeeTrainingStatus" NOT NULL,
|
||||
"notes" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"created_by" UUID,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_by" UUID,
|
||||
|
||||
CONSTRAINT "employee_trainings_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "employee_certificates" (
|
||||
"id" UUID NOT NULL,
|
||||
"employee_id" UUID NOT NULL,
|
||||
"name" TEXT NOT NULL,
|
||||
"issuer" TEXT NOT NULL,
|
||||
"obtained_date" DATE NOT NULL,
|
||||
"expiry_date" DATE,
|
||||
"certificate_no" TEXT,
|
||||
"attachment_path" TEXT,
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"created_by" UUID,
|
||||
"updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
"updated_by" UUID,
|
||||
|
||||
CONSTRAINT "employee_certificates_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_employee_trainings_employee_start" ON "employee_trainings"("employee_id", "start_date");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_employee_trainings_employee_status" ON "employee_trainings"("employee_id", "status");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_employee_certificates_employee_obtained" ON "employee_certificates"("employee_id", "obtained_date");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "idx_employee_certificates_employee_expiry" ON "employee_certificates"("employee_id", "expiry_date");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "employee_trainings" ADD CONSTRAINT "employee_trainings_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "employee_certificates" ADD CONSTRAINT "employee_certificates_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -350,6 +350,19 @@ enum EmployeeContractType {
|
||||
internship
|
||||
}
|
||||
|
||||
enum EmployeeTrainingType {
|
||||
internal
|
||||
external
|
||||
online
|
||||
}
|
||||
|
||||
enum EmployeeTrainingStatus {
|
||||
planned
|
||||
in_progress
|
||||
completed
|
||||
cancelled
|
||||
}
|
||||
|
||||
enum WeeklyReportStatus {
|
||||
draft
|
||||
submitted
|
||||
@@ -594,6 +607,8 @@ model Employee {
|
||||
owned_contract_registries ContractRegistry[] @relation("ContractRegistryOwner")
|
||||
owned_confidential_document_refs ConfidentialDocumentRef[] @relation("ConfidentialDocumentRefOwner")
|
||||
contracts EmployeeContract[]
|
||||
trainings EmployeeTraining[]
|
||||
certificates EmployeeCertificate[]
|
||||
|
||||
@@index([department_id])
|
||||
@@index([legal_entity_id], map: "idx_employees_legal_entity")
|
||||
@@ -2007,6 +2022,50 @@ model EmployeeContract {
|
||||
@@map("employee_contracts")
|
||||
}
|
||||
|
||||
model EmployeeTraining {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
employee_id String @db.Uuid
|
||||
name String
|
||||
training_type EmployeeTrainingType
|
||||
start_date DateTime @db.Date
|
||||
end_date DateTime? @db.Date
|
||||
status EmployeeTrainingStatus
|
||||
notes String?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
employee Employee @relation(fields: [employee_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([employee_id, start_date], map: "idx_employee_trainings_employee_start")
|
||||
@@index([employee_id, status], map: "idx_employee_trainings_employee_status")
|
||||
@@map("employee_trainings")
|
||||
}
|
||||
|
||||
model EmployeeCertificate {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
employee_id String @db.Uuid
|
||||
name String
|
||||
issuer String
|
||||
obtained_date DateTime @db.Date
|
||||
expiry_date DateTime? @db.Date
|
||||
certificate_no String?
|
||||
attachment_path String?
|
||||
|
||||
created_at DateTime @default(now())
|
||||
created_by String? @db.Uuid
|
||||
updated_at DateTime @default(now()) @updatedAt
|
||||
updated_by String? @db.Uuid
|
||||
|
||||
employee Employee @relation(fields: [employee_id], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([employee_id, obtained_date], map: "idx_employee_certificates_employee_obtained")
|
||||
@@index([employee_id, expiry_date], map: "idx_employee_certificates_employee_expiry")
|
||||
@@map("employee_certificates")
|
||||
}
|
||||
|
||||
model ProjectDeliveryRecord {
|
||||
id String @id @default(uuid()) @db.Uuid
|
||||
project_id String @db.Uuid
|
||||
|
||||
在新工单中引用
屏蔽一个用户