TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1CREATE TABLE "arena_votes" (2 "id" text PRIMARY KEY NOT NULL,3 "user_id" text NOT NULL,4 "session_id" text NOT NULL,5 "response_id" text NOT NULL,6 "model_key" text NOT NULL,7 "criterion" text NOT NULL,8 "category" text,9 "created_at" timestamp with time zone DEFAULT now() NOT NULL10);11--> statement-breakpoint12CREATE TABLE "custom_endpoints" (13 "id" text PRIMARY KEY NOT NULL,14 "user_id" text NOT NULL,15 "name" text NOT NULL,16 "base_url" text NOT NULL,17 "encrypted_key" text,18 "key_hint" text,19 "encrypted_headers" text,20 "models_path" text DEFAULT '/models' NOT NULL,21 "manual_models" jsonb DEFAULT '[]'::jsonb NOT NULL,22 "status" text DEFAULT 'unverified' NOT NULL,23 "last_validated_at" timestamp with time zone,24 "last_validation_error" text,25 "last_latency_ms" integer,26 "models_available" integer,27 "created_at" timestamp with time zone DEFAULT now() NOT NULL,28 "updated_at" timestamp with time zone DEFAULT now() NOT NULL29);30--> statement-breakpoint31CREATE TABLE "project_files" (32 "id" text PRIMARY KEY NOT NULL,33 "user_id" text NOT NULL,34 "project_id" text,35 "kind" text NOT NULL,36 "name" text NOT NULL,37 "mime_type" text NOT NULL,38 "size_bytes" integer NOT NULL,39 "data_base64" text NOT NULL,40 "width" integer,41 "height" integer,42 "estimated_tokens" integer,43 "description" text,44 "created_at" timestamp with time zone DEFAULT now() NOT NULL45);46--> statement-breakpoint47CREATE TABLE "projects" (48 "id" text PRIMARY KEY NOT NULL,49 "user_id" text NOT NULL,50 "name" text NOT NULL,51 "description" text,52 "icon" text,53 "color" text,54 "instructions" text,55 "preferred_model_keys" jsonb DEFAULT '[]'::jsonb NOT NULL,56 "default_settings" jsonb DEFAULT '{}'::jsonb NOT NULL,57 "notes" text,58 "archived" boolean DEFAULT false NOT NULL,59 "sort_order" integer DEFAULT 0 NOT NULL,60 "created_at" timestamp with time zone DEFAULT now() NOT NULL,61 "updated_at" timestamp with time zone DEFAULT now() NOT NULL62);63--> statement-breakpoint64CREATE TABLE "prompts" (65 "id" text PRIMARY KEY NOT NULL,66 "user_id" text NOT NULL,67 "project_id" text,68 "kind" text DEFAULT 'user' NOT NULL,69 "name" text NOT NULL,70 "description" text,71 "content" text NOT NULL,72 "variables" jsonb DEFAULT '[]'::jsonb NOT NULL,73 "schema" jsonb,74 "folder" text,75 "tags" jsonb DEFAULT '[]'::jsonb NOT NULL,76 "favorite" boolean DEFAULT false NOT NULL,77 "default_model_key" text,78 "uses" integer DEFAULT 0 NOT NULL,79 "last_used_at" timestamp with time zone,80 "created_at" timestamp with time zone DEFAULT now() NOT NULL,81 "updated_at" timestamp with time zone DEFAULT now() NOT NULL82);83--> statement-breakpoint84CREATE TABLE "shared_arena_sessions" (85 "id" text PRIMARY KEY NOT NULL,86 "session_id" text NOT NULL,87 "user_id" text NOT NULL,88 "snapshot" jsonb NOT NULL,89 "is_public" boolean DEFAULT true NOT NULL,90 "view_count" integer DEFAULT 0 NOT NULL,91 "created_at" timestamp with time zone DEFAULT now() NOT NULL,92 "revoked_at" timestamp with time zone93);94--> statement-breakpoint95CREATE TABLE "user_model_labels" (96 "user_id" text NOT NULL,97 "model_key" text NOT NULL,98 "label" text NOT NULL,99 "updated_at" timestamp with time zone DEFAULT now() NOT NULL,100 CONSTRAINT "user_model_labels_user_id_model_key_pk" PRIMARY KEY("user_id","model_key")101);102--> statement-breakpoint103ALTER TABLE "conversations" ADD COLUMN "project_id" text;--> statement-breakpoint104ALTER TABLE "arena_votes" ADD CONSTRAINT "arena_votes_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint105ALTER TABLE "custom_endpoints" ADD CONSTRAINT "custom_endpoints_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint106ALTER TABLE "project_files" ADD CONSTRAINT "project_files_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint107ALTER TABLE "project_files" ADD CONSTRAINT "project_files_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint108ALTER TABLE "projects" ADD CONSTRAINT "projects_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint109ALTER TABLE "prompts" ADD CONSTRAINT "prompts_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint110ALTER TABLE "prompts" ADD CONSTRAINT "prompts_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint111ALTER TABLE "shared_arena_sessions" ADD CONSTRAINT "shared_arena_sessions_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint112ALTER TABLE "user_model_labels" ADD CONSTRAINT "user_model_labels_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint113CREATE UNIQUE INDEX "arena_votes_session_criterion_uq" ON "arena_votes" USING btree ("session_id","criterion");--> statement-breakpoint114CREATE INDEX "arena_votes_user_model_idx" ON "arena_votes" USING btree ("user_id","model_key");--> statement-breakpoint115CREATE INDEX "custom_endpoints_user_idx" ON "custom_endpoints" USING btree ("user_id");--> statement-breakpoint116CREATE INDEX "project_files_user_idx" ON "project_files" USING btree ("user_id");--> statement-breakpoint117CREATE INDEX "project_files_project_idx" ON "project_files" USING btree ("project_id");--> statement-breakpoint118CREATE INDEX "projects_user_idx" ON "projects" USING btree ("user_id");--> statement-breakpoint119CREATE INDEX "prompts_user_idx" ON "prompts" USING btree ("user_id");--> statement-breakpoint120CREATE INDEX "prompts_user_folder_idx" ON "prompts" USING btree ("user_id","folder");--> statement-breakpoint121CREATE INDEX "shared_arena_session_idx" ON "shared_arena_sessions" USING btree ("session_id");--> statement-breakpoint122CREATE INDEX "conversations_user_project_idx" ON "conversations" USING btree ("user_id","project_id");