文件
hyb-oa/server/prisma/migrations/20260526211500_email_code_login/migration.sql
T

25 行
824 B
SQL

CREATE TABLE "email_login_codes" (
"id" UUID NOT NULL,
"employee_id" UUID NOT NULL,
"code_hash" TEXT NOT NULL,
"expires_at" TIMESTAMP(3) NOT NULL,
"used_at" TIMESTAMP(3),
"attempts_count" INTEGER NOT NULL DEFAULT 0,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"created_ip" TEXT,
"created_user_agent" TEXT,
CONSTRAINT "email_login_codes_pkey" PRIMARY KEY ("id")
);
CREATE INDEX "email_login_codes_employee_id_created_at_idx"
ON "email_login_codes"("employee_id", "created_at");
CREATE INDEX "email_login_codes_expires_at_idx"
ON "email_login_codes"("expires_at");
ALTER TABLE "email_login_codes"
ADD CONSTRAINT "email_login_codes_employee_id_fkey"
FOREIGN KEY ("employee_id") REFERENCES "employees"("id")
ON DELETE RESTRICT ON UPDATE CASCADE;