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 $$;