R45 A2-A7 员工附件与培训证书管理

这个提交包含在:
2026-03-29 13:31:53 +08:00
父节点 d11f5593d1
当前提交 48f395e18d
共修改 14 个文件,包含 2291 行新增和 22 行删除
@@ -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;