-- CreateTable
CREATE TABLE "platform_automation"."dingtalk_leave_quota_snapshots" (
    "id" UUID NOT NULL,
    "user_id" TEXT NOT NULL,
    "employee_name" TEXT NOT NULL,
    "employee_number" TEXT NOT NULL DEFAULT '',
    "leave_code" TEXT NOT NULL,
    "leave_type" TEXT NOT NULL,
    "quota_cycle" TEXT NOT NULL DEFAULT '',
    "total_days" DECIMAL(10,2) NOT NULL DEFAULT 0,
    "used_days" DECIMAL(10,2) NOT NULL DEFAULT 0,
    "remaining_days" DECIMAL(10,2) NOT NULL DEFAULT 0,
    "start_date" DATE,
    "end_date" DATE,
    "snapshot_at" TIMESTAMPTZ(3) NOT NULL,
    "created_at" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMPTZ(3) NOT NULL,

    CONSTRAINT "dingtalk_leave_quota_snapshots_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "dingtalk_leave_quota_snapshots_user_period_key" ON "platform_automation"."dingtalk_leave_quota_snapshots"("user_id", "leave_code", "quota_cycle", "start_date", "end_date");

-- CreateIndex
CREATE INDEX "dingtalk_leave_quota_snapshots_user_id_idx" ON "platform_automation"."dingtalk_leave_quota_snapshots"("user_id");

-- CreateIndex
CREATE INDEX "dingtalk_leave_quota_snapshots_leave_code_idx" ON "platform_automation"."dingtalk_leave_quota_snapshots"("leave_code");

-- CreateIndex
CREATE INDEX "dingtalk_leave_quota_snapshots_snapshot_at_idx" ON "platform_automation"."dingtalk_leave_quota_snapshots"("snapshot_at");
