ai-chatbot/lib/db/migrations/0043_add_email_verification.sql
Your Name aa1ec8bd43
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat: add email verification with resend auth settings
2026-02-23 12:31:41 +08:00

21 lines
806 B
SQL

ALTER TABLE "AuthSettings"
ADD COLUMN IF NOT EXISTS "isEmailVerificationEnabled" boolean NOT NULL DEFAULT false;
ALTER TABLE "AuthSettings"
ADD COLUMN IF NOT EXISTS "emailVerificationExpiresMinutes" integer NOT NULL DEFAULT 10;
CREATE TABLE IF NOT EXISTS "EmailVerificationCode" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"email" varchar(64) NOT NULL,
"purpose" varchar(32) NOT NULL DEFAULT 'register',
"codeHash" varchar(128) NOT NULL,
"expiresAt" timestamp NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS "EmailVerificationCode_email_purpose_createdAt_idx"
ON "EmailVerificationCode" ("email", "purpose", "createdAt");
CREATE INDEX IF NOT EXISTS "EmailVerificationCode_expiresAt_idx"
ON "EmailVerificationCode" ("expiresAt");