Skip to content
65 changes: 65 additions & 0 deletions backend/drizzle/0017_superb_sentinels.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
CREATE TYPE "public"."playground_message_role" AS ENUM('system', 'user', 'assistant');--> statement-breakpoint
CREATE TYPE "public"."playground_test_result_status" AS ENUM('pending', 'running', 'completed', 'failed');--> statement-breakpoint
CREATE TABLE "playground_conversations" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "playground_conversations_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"title" varchar(255) NOT NULL,
"model" varchar(63) NOT NULL,
"api_key_id" integer,
"params" jsonb,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"deleted" boolean DEFAULT false NOT NULL
);
--> statement-breakpoint
CREATE TABLE "playground_messages" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "playground_messages_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"conversation_id" integer NOT NULL,
"role" "playground_message_role" NOT NULL,
"content" varchar NOT NULL,
"completion_id" integer,
"created_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "playground_test_cases" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "playground_test_cases_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"title" varchar(255) NOT NULL,
"description" varchar,
"messages" jsonb NOT NULL,
"params" jsonb,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL,
"deleted" boolean DEFAULT false NOT NULL
);
--> statement-breakpoint
CREATE TABLE "playground_test_results" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "playground_test_results_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"test_run_id" integer NOT NULL,
"model" varchar(63) NOT NULL,
"status" "playground_test_result_status" DEFAULT 'pending' NOT NULL,
"response" varchar,
"prompt_tokens" integer,
"completion_tokens" integer,
"ttft" integer,
"duration" integer,
"error_message" varchar,
"completion_id" integer,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT now() NOT NULL
);
--> statement-breakpoint
CREATE TABLE "playground_test_runs" (
"id" integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY (sequence name "playground_test_runs_id_seq" INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START WITH 1 CACHE 1),
"test_case_id" integer NOT NULL,
"api_key_id" integer,
"models" jsonb NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"deleted" boolean DEFAULT false NOT NULL
);
--> statement-breakpoint
ALTER TABLE "playground_conversations" ADD CONSTRAINT "playground_conversations_api_key_id_api_keys_id_fk" FOREIGN KEY ("api_key_id") REFERENCES "public"."api_keys"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_messages" ADD CONSTRAINT "playground_messages_conversation_id_playground_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."playground_conversations"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_messages" ADD CONSTRAINT "playground_messages_completion_id_completions_id_fk" FOREIGN KEY ("completion_id") REFERENCES "public"."completions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_results" ADD CONSTRAINT "playground_test_results_test_run_id_playground_test_runs_id_fk" FOREIGN KEY ("test_run_id") REFERENCES "public"."playground_test_runs"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_results" ADD CONSTRAINT "playground_test_results_completion_id_completions_id_fk" FOREIGN KEY ("completion_id") REFERENCES "public"."completions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_runs" ADD CONSTRAINT "playground_test_runs_test_case_id_playground_test_cases_id_fk" FOREIGN KEY ("test_case_id") REFERENCES "public"."playground_test_cases"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_runs" ADD CONSTRAINT "playground_test_runs_api_key_id_api_keys_id_fk" FOREIGN KEY ("api_key_id") REFERENCES "public"."api_keys"("id") ON DELETE no action ON UPDATE no action;
21 changes: 21 additions & 0 deletions backend/drizzle/0018_messy_spectrum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ALTER TABLE "playground_conversations" DROP CONSTRAINT "playground_conversations_api_key_id_api_keys_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_messages" DROP CONSTRAINT "playground_messages_conversation_id_playground_conversations_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_messages" DROP CONSTRAINT "playground_messages_completion_id_completions_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_test_results" DROP CONSTRAINT "playground_test_results_test_run_id_playground_test_runs_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_test_results" DROP CONSTRAINT "playground_test_results_completion_id_completions_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_test_runs" DROP CONSTRAINT "playground_test_runs_test_case_id_playground_test_cases_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_test_runs" DROP CONSTRAINT "playground_test_runs_api_key_id_api_keys_id_fk";
--> statement-breakpoint
ALTER TABLE "playground_conversations" ADD CONSTRAINT "playground_conversations_api_key_id_api_keys_id_fk" FOREIGN KEY ("api_key_id") REFERENCES "public"."api_keys"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_messages" ADD CONSTRAINT "playground_messages_conversation_id_playground_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."playground_conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_messages" ADD CONSTRAINT "playground_messages_completion_id_completions_id_fk" FOREIGN KEY ("completion_id") REFERENCES "public"."completions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_results" ADD CONSTRAINT "playground_test_results_test_run_id_playground_test_runs_id_fk" FOREIGN KEY ("test_run_id") REFERENCES "public"."playground_test_runs"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_results" ADD CONSTRAINT "playground_test_results_completion_id_completions_id_fk" FOREIGN KEY ("completion_id") REFERENCES "public"."completions"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_runs" ADD CONSTRAINT "playground_test_runs_test_case_id_playground_test_cases_id_fk" FOREIGN KEY ("test_case_id") REFERENCES "public"."playground_test_cases"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "playground_test_runs" ADD CONSTRAINT "playground_test_runs_api_key_id_api_keys_id_fk" FOREIGN KEY ("api_key_id") REFERENCES "public"."api_keys"("id") ON DELETE set null ON UPDATE no action;
121 changes: 28 additions & 93 deletions backend/drizzle/meta/0008_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
"api_keys_key_unique": {
"name": "api_keys_key_unique",
"nullsNotDistinct": false,
"columns": [
"key"
]
"columns": ["key"]
}
},
"policies": {},
Expand Down Expand Up @@ -224,25 +222,17 @@
"name": "completions_api_key_id_api_keys_id_fk",
"tableFrom": "completions",
"tableTo": "api_keys",
"columnsFrom": [
"api_key_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["api_key_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"completions_upstream_id_upstreams_id_fk": {
"name": "completions_upstream_id_upstreams_id_fk",
"tableFrom": "completions",
"tableTo": "upstreams",
"columnsFrom": [
"upstream_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["upstream_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand All @@ -252,9 +242,7 @@
"completions_id_unique": {
"name": "completions_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
"columns": ["id"]
}
},
"policies": {},
Expand Down Expand Up @@ -366,25 +354,17 @@
"name": "embeddings_api_key_id_api_keys_id_fk",
"tableFrom": "embeddings",
"tableTo": "api_keys",
"columnsFrom": [
"api_key_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["api_key_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"embeddings_model_id_models_id_fk": {
"name": "embeddings_model_id_models_id_fk",
"tableFrom": "embeddings",
"tableTo": "models",
"columnsFrom": [
"model_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["model_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand All @@ -394,9 +374,7 @@
"embeddings_id_unique": {
"name": "embeddings_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
"columns": ["id"]
}
},
"policies": {},
Expand Down Expand Up @@ -509,12 +487,8 @@
"name": "models_provider_id_providers_id_fk",
"tableFrom": "models",
"tableTo": "providers",
"columnsFrom": [
"provider_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["provider_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand All @@ -524,10 +498,7 @@
"models_provider_system_name_unique": {
"name": "models_provider_system_name_unique",
"nullsNotDistinct": false,
"columns": [
"provider_id",
"system_name"
]
"columns": ["provider_id", "system_name"]
}
},
"policies": {},
Expand Down Expand Up @@ -622,9 +593,7 @@
"providers_name_unique": {
"name": "providers_name_unique",
"nullsNotDistinct": false,
"columns": [
"name"
]
"columns": ["name"]
}
},
"policies": {},
Expand Down Expand Up @@ -679,9 +648,7 @@
"settings_key_unique": {
"name": "settings_key_unique",
"nullsNotDistinct": false,
"columns": [
"key"
]
"columns": ["key"]
}
},
"policies": {},
Expand Down Expand Up @@ -773,38 +740,26 @@
"name": "srv_logs_related_api_key_id_api_keys_id_fk",
"tableFrom": "srv_logs",
"tableTo": "api_keys",
"columnsFrom": [
"related_api_key_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["related_api_key_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"srv_logs_related_upstream_id_upstreams_id_fk": {
"name": "srv_logs_related_upstream_id_upstreams_id_fk",
"tableFrom": "srv_logs",
"tableTo": "upstreams",
"columnsFrom": [
"related_upstream_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["related_upstream_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
},
"srv_logs_related_completion_id_completions_id_fk": {
"name": "srv_logs_related_completion_id_completions_id_fk",
"tableFrom": "srv_logs",
"tableTo": "completions",
"columnsFrom": [
"related_completion_id"
],
"columnsTo": [
"id"
],
"columnsFrom": ["related_completion_id"],
"columnsTo": ["id"],
"onDelete": "no action",
"onUpdate": "no action"
}
Expand All @@ -814,9 +769,7 @@
"srv_logs_id_unique": {
"name": "srv_logs_id_unique",
"nullsNotDistinct": false,
"columns": [
"id"
]
"columns": ["id"]
}
},
"policies": {},
Expand Down Expand Up @@ -922,40 +875,22 @@
"public.completions_status": {
"name": "completions_status",
"schema": "public",
"values": [
"pending",
"completed",
"failed"
]
"values": ["pending", "completed", "failed"]
},
"public.model_type": {
"name": "model_type",
"schema": "public",
"values": [
"chat",
"embedding"
]
"values": ["chat", "embedding"]
},
"public.provider_type": {
"name": "provider_type",
"schema": "public",
"values": [
"openai",
"openai-responses",
"anthropic",
"azure",
"ollama"
]
"values": ["openai", "openai-responses", "anthropic", "azure", "ollama"]
},
"public.srv_logs_level": {
"name": "srv_logs_level",
"schema": "public",
"values": [
"unspecific",
"info",
"warn",
"error"
]
"values": ["unspecific", "info", "warn", "error"]
}
},
"schemas": {},
Expand All @@ -968,4 +903,4 @@
"schemas": {},
"tables": {}
}
}
}
Loading