ai-chatbot/lib/db/migrations/0010_eminent_sinister_six.sql
Your Name 53ddb7e585
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
Initial commit - clean repository
2025-12-17 20:15:18 +08:00

57 lines
2.0 KiB
SQL

CREATE TABLE IF NOT EXISTS "AuthSettings" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"dingTalkAppKey" text,
"dingTalkAppSecret" text,
"isDingTalkEnabled" boolean DEFAULT false NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL,
"updatedBy" uuid
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "LoginToken" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"token" text NOT NULL,
"email" varchar(64) NOT NULL,
"expiresAt" timestamp NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
CONSTRAINT "LoginToken_token_unique" UNIQUE("token")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "NavLinks" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"name" varchar(64) NOT NULL,
"url" text NOT NULL,
"order" integer DEFAULT 0 NOT NULL,
"isEnabled" boolean DEFAULT true NOT NULL,
"createdAt" timestamp DEFAULT now() NOT NULL,
"updatedAt" timestamp DEFAULT now() NOT NULL,
"createdBy" uuid
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "SiteSettings" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"siteName" varchar(128) DEFAULT 'AI Chatbot' NOT NULL,
"siteLogo" text,
"siteLogoDark" text,
"favicon" text,
"updatedAt" timestamp DEFAULT now() NOT NULL,
"updatedBy" uuid
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "AuthSettings" ADD CONSTRAINT "AuthSettings_updatedBy_User_id_fk" FOREIGN KEY ("updatedBy") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "NavLinks" ADD CONSTRAINT "NavLinks_createdBy_User_id_fk" FOREIGN KEY ("createdBy") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "SiteSettings" ADD CONSTRAINT "SiteSettings_updatedBy_User_id_fk" FOREIGN KEY ("updatedBy") REFERENCES "public"."User"("id") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;