CREATE TABLE "game_history" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "room_code" text NOT NULL, "played_at" timestamp with time zone DEFAULT now() NOT NULL, "modes" jsonb, "results" jsonb ); --> statement-breakpoint CREATE TABLE "quiz_category" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "name" text NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT "quiz_category_name_unique" UNIQUE("name") ); --> statement-breakpoint CREATE TABLE "quiz_played" ( "question_id" uuid NOT NULL, "room_code" text NOT NULL, "played_at" timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT "quiz_played_question_id_room_code_pk" PRIMARY KEY("question_id","room_code") ); --> statement-breakpoint CREATE TABLE "quiz_question" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "category_id" uuid, "format" text NOT NULL, "prompt" text NOT NULL, "difficulty" integer DEFAULT 1 NOT NULL, "source" text NOT NULL, "choices" jsonb, "correct_index" integer, "accepted_answers" jsonb, "image_url" text, "created_at" timestamp with time zone DEFAULT now() NOT NULL, CONSTRAINT "quiz_question_prompt_unique" UNIQUE("prompt") ); --> statement-breakpoint ALTER TABLE "quiz_played" ADD CONSTRAINT "quiz_played_question_id_quiz_question_id_fk" FOREIGN KEY ("question_id") REFERENCES "public"."quiz_question"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint ALTER TABLE "quiz_question" ADD CONSTRAINT "quiz_question_category_id_quiz_category_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."quiz_category"("id") ON DELETE no action ON UPDATE no action;