CREATE TABLE "attendance_records" ( "id" UUID NOT NULL, "employee_id" UUID NOT NULL, "work_date" DATE NOT NULL, "clock_in_at" TIMESTAMP(3), "clock_out_at" TIMESTAMP(3), "work_minutes" INTEGER, "is_late" BOOLEAN NOT NULL DEFAULT false, "late_minutes" INTEGER NOT NULL DEFAULT 0, "is_early_leave" BOOLEAN NOT NULL DEFAULT false, "early_minutes" INTEGER NOT NULL DEFAULT 0, "note" TEXT, "source" VARCHAR(16) NOT NULL DEFAULT 'web', "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_by" UUID, CONSTRAINT "attendance_records_pkey" PRIMARY KEY ("id") ); CREATE TABLE "attendance_policies" ( "id" UUID NOT NULL, "work_start_time" VARCHAR(5) NOT NULL DEFAULT '09:00', "work_end_time" VARCHAR(5) NOT NULL DEFAULT '18:00', "lunch_start_time" VARCHAR(5) NOT NULL DEFAULT '12:00', "lunch_end_time" VARCHAR(5) NOT NULL DEFAULT '13:00', "late_tolerance_minutes" INTEGER NOT NULL DEFAULT 0, "enabled" BOOLEAN NOT NULL DEFAULT true, "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updated_by" UUID, CONSTRAINT "attendance_policies_pkey" PRIMARY KEY ("id") ); CREATE UNIQUE INDEX "attendance_records_employee_date_ux" ON "attendance_records"("employee_id", "work_date"); CREATE INDEX "idx_attendance_records_work_date" ON "attendance_records"("work_date"); ALTER TABLE "attendance_records" ADD CONSTRAINT "attendance_records_employee_id_fkey" FOREIGN KEY ("employee_id") REFERENCES "employees"("id") ON DELETE CASCADE ON UPDATE CASCADE;