CREATE TABLE "comparison_dimensions" ( "id" text PRIMARY KEY NOT NULL, "comparison_id" text NOT NULL, "name" text NOT NULL, "description" text, "weight" integer DEFAULT 1, "order" integer NOT NULL ); --> statement-breakpoint CREATE TABLE "comparison_items" ( "id" text PRIMARY KEY NOT NULL, "comparison_id" text NOT NULL, "name" text NOT NULL, "description" text, "image_url" text, "research_data" jsonb, "scores" jsonb, "pros" text[], "cons" text[], "order" integer NOT NULL ); --> statement-breakpoint CREATE TABLE "comparisons" ( "id" text PRIMARY KEY NOT NULL, "user_id" text, "title" text NOT NULL, "query" text, "slug" varchar(255) NOT NULL, "status" text DEFAULT 'researching' NOT NULL, "summary" text, "overall_data" jsonb, "tags" text[], "is_public" boolean DEFAULT false, "view_count" integer DEFAULT 0, "created_at" timestamp DEFAULT now() NOT NULL, "updated_at" timestamp DEFAULT now() NOT NULL, CONSTRAINT "comparisons_slug_unique" UNIQUE("slug") ); --> statement-breakpoint ALTER TABLE "comparison_dimensions" ADD CONSTRAINT "comparison_dimensions_comparison_id_comparisons_id_fk" FOREIGN KEY ("comparison_id") REFERENCES "public"."comparisons"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint ALTER TABLE "comparison_items" ADD CONSTRAINT "comparison_items_comparison_id_comparisons_id_fk" FOREIGN KEY ("comparison_id") REFERENCES "public"."comparisons"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint CREATE INDEX "comparisons_user_id_idx" ON "comparisons" USING btree ("user_id");