Files
2026-07-22 13:48:46 +08:00

19 lines
907 B
SQL

CREATE TABLE IF NOT EXISTS "public"."prompts" (
"id" bigint generated by default as identity not null,
"created_at" timestamp with time zone not null default now(),
"user_id" "uuid" NOT NULL,
"type" "public"."prompt_type" DEFAULT 'chat'::"public"."prompt_type" NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS prompts_pkey ON "public"."prompts" USING btree (id);
ALTER TABLE "public"."prompts" ADD CONSTRAINT "prompts_pkey" PRIMARY KEY USING INDEX "prompts_pkey";
ALTER TABLE "public"."prompts" ADD CONSTRAINT "prompts_user_id_fkey" FOREIGN KEY (user_id) REFERENCES auth.users(id) ON UPDATE CASCADE ON DELETE CASCADE not valid;
ALTER TABLE "public"."prompts" VALIDATE CONSTRAINT "prompts_user_id_fkey";
CREATE POLICY "Users can view their own prompts" ON "public"."prompts" FOR SELECT USING ((SELECT "auth"."uid"()) = "user_id");
ALTER TABLE "public"."prompts" ENABLE ROW LEVEL SECURITY;