diff --git a/frontend/lib/db/migrations/0002_next_tusk.sql b/frontend/lib/db/migrations/0002_cold_romulus.sql similarity index 92% rename from frontend/lib/db/migrations/0002_next_tusk.sql rename to frontend/lib/db/migrations/0002_cold_romulus.sql index acb6bbdf..232ded6c 100644 --- a/frontend/lib/db/migrations/0002_next_tusk.sql +++ b/frontend/lib/db/migrations/0002_cold_romulus.sql @@ -2,8 +2,8 @@ CREATE TABLE IF NOT EXISTS "labeling_queue_data" ( "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, "created_at" timestamp with time zone DEFAULT now() NOT NULL, "queue_id" uuid DEFAULT gen_random_uuid() NOT NULL, - "data" jsonb NOT NULL, - "action" jsonb NOT NULL + "action" jsonb NOT NULL, + "span_id" uuid NOT NULL ); --> statement-breakpoint ALTER TABLE "dataset_datapoints" ALTER COLUMN "target" DROP NOT NULL;--> statement-breakpoint diff --git a/frontend/lib/db/migrations/0003_cultured_tinkerer.sql b/frontend/lib/db/migrations/0003_cultured_tinkerer.sql new file mode 100644 index 00000000..5edea527 --- /dev/null +++ b/frontend/lib/db/migrations/0003_cultured_tinkerer.sql @@ -0,0 +1,29 @@ +ALTER TABLE "labels" DROP CONSTRAINT "trace_tags_span_id_fkey"; +--> statement-breakpoint +/* + [SOLVED] + Unfortunately in current drizzle-kit version we can't automatically get name for primary key. + We are working on making it available! + + Meanwhile you can: + 1. Check pk name in your database, by running + SELECT constraint_name FROM information_schema.table_constraints + WHERE table_schema = 'public' + AND table_name = 'spans' + AND constraint_type = 'PRIMARY KEY'; + 2. Uncomment code below and paste pk name manually + + Hope to release this update as soon as possible +*/ + +ALTER TABLE "spans" DROP CONSTRAINT "spans_pkey";--> statement-breakpoint +ALTER TABLE "spans" ADD COLUMN "project_id" uuid NOT NULL;--> statement-breakpoint +ALTER TABLE "spans" ADD CONSTRAINT "spans_pkey" PRIMARY KEY("span_id","project_id");--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "spans" ADD CONSTRAINT "spans_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE no action ON UPDATE cascade; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +CREATE INDEX IF NOT EXISTS "spans_project_id_idx" ON "spans" USING btree ("project_id");--> statement-breakpoint +ALTER TABLE "spans" ADD CONSTRAINT "unique_span_id_project_id" UNIQUE("span_id","project_id"); \ No newline at end of file diff --git a/frontend/lib/db/migrations/meta/0002_snapshot.json b/frontend/lib/db/migrations/meta/0002_snapshot.json index 1f6bc6c6..c5c8e3d6 100644 --- a/frontend/lib/db/migrations/meta/0002_snapshot.json +++ b/frontend/lib/db/migrations/meta/0002_snapshot.json @@ -1,5 +1,5 @@ { - "id": "4bf43179-5f48-4c3e-b1f0-033007c3a0c9", + "id": "326ba2ca-6925-4d69-8416-1a7691a8bcfd", "prevId": "a7f4ca0c-430b-49f5-93d4-09d1ab968dac", "version": "7", "dialect": "postgresql", @@ -742,15 +742,15 @@ "notNull": true, "default": "gen_random_uuid()" }, - "data": { - "name": "data", + "action": { + "name": "action", "type": "jsonb", "primaryKey": false, "notNull": true }, - "action": { - "name": "action", - "type": "jsonb", + "span_id": { + "name": "span_id", + "type": "uuid", "primaryKey": false, "notNull": true } diff --git a/frontend/lib/db/migrations/meta/0003_snapshot.json b/frontend/lib/db/migrations/meta/0003_snapshot.json new file mode 100644 index 00000000..7d7a7a43 --- /dev/null +++ b/frontend/lib/db/migrations/meta/0003_snapshot.json @@ -0,0 +1,2481 @@ +{ + "id": "2bfae944-3896-4b39-b7e0-d1103db2d9d1", + "prevId": "326ba2ca-6925-4d69-8416-1a7691a8bcfd", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.api_keys": { + "name": "api_keys", + "schema": "", + "columns": { + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + } + }, + "indexes": {}, + "foreignKeys": { + "api_keys_user_id_fkey": { + "name": "api_keys_user_id_fkey", + "tableFrom": "api_keys", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.dataset_datapoints": { + "name": "dataset_datapoints", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "dataset_id": { + "name": "dataset_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "indexed_on": { + "name": "indexed_on", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "index_in_batch": { + "name": "index_in_batch", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "dataset_datapoints_dataset_id_fkey": { + "name": "dataset_datapoints_dataset_id_fkey", + "tableFrom": "dataset_datapoints", + "tableTo": "datasets", + "columnsFrom": [ + "dataset_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.datasets": { + "name": "datasets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "indexed_on": { + "name": "indexed_on", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "public_datasets_project_id_fkey": { + "name": "public_datasets_project_id_fkey", + "tableFrom": "datasets", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.evaluation_results": { + "name": "evaluation_results", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "evaluation_id": { + "name": "evaluation_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "target": { + "name": "target", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "executor_output": { + "name": "executor_output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "index_in_batch": { + "name": "index_in_batch", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "scores": { + "name": "scores", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "trace_id": { + "name": "trace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "evaluation_results_evaluation_id_idx": { + "name": "evaluation_results_evaluation_id_idx", + "columns": [ + { + "expression": "evaluation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "evaluation_results_evaluation_id_fkey1": { + "name": "evaluation_results_evaluation_id_fkey1", + "tableFrom": "evaluation_results", + "tableTo": "evaluations", + "columnsFrom": [ + "evaluation_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.evaluation_scores": { + "name": "evaluation_scores", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "result_id": { + "name": "result_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "score": { + "name": "score", + "type": "double precision", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "evaluation_scores_result_id_fkey": { + "name": "evaluation_scores_result_id_fkey", + "tableFrom": "evaluation_scores", + "tableTo": "evaluation_results", + "columnsFrom": [ + "result_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.evaluations": { + "name": "evaluations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + } + }, + "indexes": {}, + "foreignKeys": { + "evaluations_project_id_fkey1": { + "name": "evaluations_project_id_fkey1", + "tableFrom": "evaluations", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.event_templates": { + "name": "event_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "event_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'BOOLEAN'" + } + }, + "indexes": {}, + "foreignKeys": { + "event_templates_project_id_fkey": { + "name": "event_templates_project_id_fkey", + "tableFrom": "event_templates", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_name_project_id": { + "name": "unique_name_project_id", + "nullsNotDistinct": false, + "columns": [ + "name", + "project_id" + ] + } + }, + "checkConstraints": {} + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "span_id": { + "name": "span_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "template_id": { + "name": "template_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "event_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "inputs": { + "name": "inputs", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "events_template_id_fkey": { + "name": "events_template_id_fkey", + "tableFrom": "events", + "tableTo": "event_templates", + "columnsFrom": [ + "template_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.label_classes": { + "name": "label_classes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "label_type": { + "name": "label_type", + "type": "label_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "value_map": { + "name": "value_map", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[false,true]'::jsonb" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "evaluator_runnable_graph": { + "name": "evaluator_runnable_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "pipeline_version_id": { + "name": "pipeline_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "label_classes_project_id_fkey": { + "name": "label_classes_project_id_fkey", + "tableFrom": "label_classes", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.label_classes_for_path": { + "name": "label_classes_for_path", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label_class_id": { + "name": "label_class_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "autoeval_labels_project_id_fkey": { + "name": "autoeval_labels_project_id_fkey", + "tableFrom": "label_classes_for_path", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_project_id_path_label_class": { + "name": "unique_project_id_path_label_class", + "nullsNotDistinct": false, + "columns": [ + "project_id", + "path", + "label_class_id" + ] + } + }, + "checkConstraints": {} + }, + "public.labeling_queue_data": { + "name": "labeling_queue_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "queue_id": { + "name": "queue_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "action": { + "name": "action", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "span_id": { + "name": "span_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "labelling_queue_data_queue_id_fkey": { + "name": "labelling_queue_data_queue_id_fkey", + "tableFrom": "labeling_queue_data", + "tableTo": "labeling_queues", + "columnsFrom": [ + "queue_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.labeling_queues": { + "name": "labeling_queues", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "labeling_queues_project_id_fkey": { + "name": "labeling_queues_project_id_fkey", + "tableFrom": "labeling_queues", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.labels": { + "name": "labels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "class_id": { + "name": "class_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "double precision", + "primaryKey": false, + "notNull": false, + "default": "'0'" + }, + "span_id": { + "name": "span_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false, + "default": "gen_random_uuid()" + }, + "label_source": { + "name": "label_source", + "type": "label_source", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'MANUAL'" + }, + "job_status": { + "name": "job_status", + "type": "label_job_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "reasoning": { + "name": "reasoning", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "trace_tags_type_id_fkey": { + "name": "trace_tags_type_id_fkey", + "tableFrom": "labels", + "tableTo": "label_classes", + "columnsFrom": [ + "class_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "labels_span_id_class_id_user_id_key": { + "name": "labels_span_id_class_id_user_id_key", + "nullsNotDistinct": false, + "columns": [ + "class_id", + "span_id", + "user_id" + ] + } + }, + "checkConstraints": {} + }, + "public.llm_prices": { + "name": "llm_prices", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_price_per_million": { + "name": "input_price_per_million", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "output_price_per_million": { + "name": "output_price_per_million", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "input_cached_price_per_million": { + "name": "input_cached_price_per_million", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "additional_prices": { + "name": "additional_prices", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.members_of_workspaces": { + "name": "members_of_workspaces", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "member_role": { + "name": "member_role", + "type": "workspace_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'owner'" + } + }, + "indexes": { + "members_of_workspaces_user_id_idx": { + "name": "members_of_workspaces_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "members_of_workspaces_user_id_fkey": { + "name": "members_of_workspaces_user_id_fkey", + "tableFrom": "members_of_workspaces", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "public_members_of_workspaces_workspace_id_fkey": { + "name": "public_members_of_workspaces_workspace_id_fkey", + "tableFrom": "members_of_workspaces", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "members_of_workspaces_user_workspace_unique": { + "name": "members_of_workspaces_user_workspace_unique", + "nullsNotDistinct": false, + "columns": [ + "workspace_id", + "user_id" + ] + } + }, + "checkConstraints": {} + }, + "public.pipeline_templates": { + "name": "pipeline_templates", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "runnable_graph": { + "name": "runnable_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "displayable_graph": { + "name": "displayable_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{}'::jsonb" + }, + "number_of_nodes": { + "name": "number_of_nodes", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "display_group": { + "name": "display_group", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'build'" + }, + "ordinal": { + "name": "ordinal", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 500 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.pipeline_versions": { + "name": "pipeline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "pipeline_id": { + "name": "pipeline_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "displayable_graph": { + "name": "displayable_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "runnable_graph": { + "name": "runnable_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "pipeline_type": { + "name": "pipeline_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.pipelines": { + "name": "pipelines", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'PRIVATE'" + }, + "python_requirements": { + "name": "python_requirements", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + } + }, + "indexes": { + "pipelines_name_project_id_idx": { + "name": "pipelines_name_project_id_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "pipelines_project_id_idx": { + "name": "pipelines_project_id_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "pipelines_project_id_fkey": { + "name": "pipelines_project_id_fkey", + "tableFrom": "pipelines", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_project_id_pipeline_name": { + "name": "unique_project_id_pipeline_name", + "nullsNotDistinct": false, + "columns": [ + "project_id", + "name" + ] + } + }, + "checkConstraints": {} + }, + "public.project_api_keys": { + "name": "project_api_keys", + "schema": "", + "columns": { + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shorthand": { + "name": "shorthand", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + } + }, + "indexes": {}, + "foreignKeys": { + "public_project_api_keys_project_id_fkey": { + "name": "public_project_api_keys_project_id_fkey", + "tableFrom": "project_api_keys", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.projects": { + "name": "projects", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "projects_workspace_id_idx": { + "name": "projects_workspace_id_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "projects_workspace_id_fkey": { + "name": "projects_workspace_id_fkey", + "tableFrom": "projects", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.provider_api_keys": { + "name": "provider_api_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true, + "default": "gen_random_uuid()" + }, + "nonce_hex": { + "name": "nonce_hex", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "provider_api_keys_project_id_fkey": { + "name": "provider_api_keys_project_id_fkey", + "tableFrom": "provider_api_keys", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.spans": { + "name": "spans", + "schema": "", + "columns": { + "span_id": { + "name": "span_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "parent_span_id": { + "name": "parent_span_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "attributes": { + "name": "attributes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "input": { + "name": "input", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "output": { + "name": "output", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "span_type": { + "name": "span_type", + "type": "span_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "start_time": { + "name": "start_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "trace_id": { + "name": "trace_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "input_preview": { + "name": "input_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "output_preview": { + "name": "output_preview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "span_path_idx": { + "name": "span_path_idx", + "columns": [ + { + "expression": "(attributes -> 'lmnr.span.path'::text)", + "asc": true, + "isExpression": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_project_id_idx": { + "name": "spans_project_id_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_start_time_end_time_idx": { + "name": "spans_start_time_end_time_idx", + "columns": [ + { + "expression": "start_time", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "end_time", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "spans_trace_id_idx": { + "name": "spans_trace_id_idx", + "columns": [ + { + "expression": "trace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "new_spans_trace_id_fkey": { + "name": "new_spans_trace_id_fkey", + "tableFrom": "spans", + "tableTo": "traces", + "columnsFrom": [ + "trace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "spans_project_id_fkey": { + "name": "spans_project_id_fkey", + "tableFrom": "spans", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": { + "spans_pkey": { + "name": "spans_pkey", + "columns": [ + "span_id", + "project_id" + ] + } + }, + "uniqueConstraints": { + "unique_span_id_project_id": { + "name": "unique_span_id_project_id", + "nullsNotDistinct": false, + "columns": [ + "span_id", + "project_id" + ] + } + }, + "checkConstraints": {} + }, + "public.subscription_tiers": { + "name": "subscription_tiers", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "bigint", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "byDefault", + "name": "subscription_tiers_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "9223372036854776000", + "cache": "1", + "cycle": false + } + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "storage_mib": { + "name": "storage_mib", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "log_retention_days": { + "name": "log_retention_days", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "members_per_workspace": { + "name": "members_per_workspace", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'-1'" + }, + "num_workspaces": { + "name": "num_workspaces", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'-1'" + }, + "stripe_product_id": { + "name": "stripe_product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "events": { + "name": "events", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "spans": { + "name": "spans", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "extra_span_price": { + "name": "extra_span_price", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "extra_event_price": { + "name": "extra_event_price", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": "'0'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.target_pipeline_versions": { + "name": "target_pipeline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "pipeline_id": { + "name": "pipeline_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "pipeline_version_id": { + "name": "pipeline_version_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "target_pipeline_versions_pipeline_id_fkey": { + "name": "target_pipeline_versions_pipeline_id_fkey", + "tableFrom": "target_pipeline_versions", + "tableTo": "pipelines", + "columnsFrom": [ + "pipeline_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + }, + "target_pipeline_versions_pipeline_version_id_fkey": { + "name": "target_pipeline_versions_pipeline_version_id_fkey", + "tableFrom": "target_pipeline_versions", + "tableTo": "pipeline_versions", + "columnsFrom": [ + "pipeline_version_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "unique_pipeline_id": { + "name": "unique_pipeline_id", + "nullsNotDistinct": false, + "columns": [ + "pipeline_id" + ] + } + }, + "checkConstraints": {} + }, + "public.traces": { + "name": "traces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "version": { + "name": "version", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "release": { + "name": "release", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_id": { + "name": "session_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "project_id": { + "name": "project_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "end_time": { + "name": "end_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "start_time": { + "name": "start_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "total_token_count": { + "name": "total_token_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "success": { + "name": "success", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "cost": { + "name": "cost", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "trace_type": { + "name": "trace_type", + "type": "trace_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'DEFAULT'" + }, + "input_token_count": { + "name": "input_token_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "output_token_count": { + "name": "output_token_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "input_cost": { + "name": "input_cost", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "output_cost": { + "name": "output_cost", + "type": "double precision", + "primaryKey": false, + "notNull": true, + "default": "'0'" + } + }, + "indexes": { + "traces_project_id_idx": { + "name": "traces_project_id_idx", + "columns": [ + { + "expression": "project_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "traces_session_id_idx": { + "name": "traces_session_id_idx", + "columns": [ + { + "expression": "session_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "traces_start_time_end_time_idx": { + "name": "traces_start_time_end_time_idx", + "columns": [ + { + "expression": "start_time", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "end_time", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "new_traces_project_id_fkey": { + "name": "new_traces_project_id_fkey", + "tableFrom": "traces", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.user_subscription_info": { + "name": "user_subscription_info", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "activated": { + "name": "activated", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": { + "user_subscription_info_stripe_customer_id_idx": { + "name": "user_subscription_info_stripe_customer_id_idx", + "columns": [ + { + "expression": "stripe_customer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "user_subscription_info_fkey": { + "name": "user_subscription_info_fkey", + "tableFrom": "user_subscription_info", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_key": { + "name": "users_email_key", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "checkConstraints": {} + }, + "public.workspace_usage": { + "name": "workspace_usage", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "span_count": { + "name": "span_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "span_count_since_reset": { + "name": "span_count_since_reset", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "prev_span_count": { + "name": "prev_span_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "event_count": { + "name": "event_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "event_count_since_reset": { + "name": "event_count_since_reset", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "prev_event_count": { + "name": "prev_event_count", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "reset_time": { + "name": "reset_time", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reset_reason": { + "name": "reset_reason", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'signup'" + } + }, + "indexes": {}, + "foreignKeys": { + "user_usage_workspace_id_fkey": { + "name": "user_usage_workspace_id_fkey", + "tableFrom": "workspace_usage", + "tableTo": "workspaces", + "columnsFrom": [ + "workspace_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_usage_workspace_id_key": { + "name": "user_usage_workspace_id_key", + "nullsNotDistinct": false, + "columns": [ + "workspace_id" + ] + } + }, + "checkConstraints": {} + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tier_id": { + "name": "tier_id", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'1'" + }, + "subscription_id": { + "name": "subscription_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "additional_seats": { + "name": "additional_seats", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": "'0'" + } + }, + "indexes": {}, + "foreignKeys": { + "workspaces_tier_id_fkey": { + "name": "workspaces_tier_id_fkey", + "tableFrom": "workspaces", + "tableTo": "subscription_tiers", + "columnsFrom": [ + "tier_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "cascade" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "enums": { + "public.event_source": { + "name": "event_source", + "schema": "public", + "values": [ + "AUTO", + "MANUAL", + "CODE" + ] + }, + "public.event_type": { + "name": "event_type", + "schema": "public", + "values": [ + "BOOLEAN", + "STRING", + "NUMBER" + ] + }, + "public.label_job_status": { + "name": "label_job_status", + "schema": "public", + "values": [ + "RUNNING", + "DONE" + ] + }, + "public.label_source": { + "name": "label_source", + "schema": "public", + "values": [ + "MANUAL", + "AUTO" + ] + }, + "public.label_type": { + "name": "label_type", + "schema": "public", + "values": [ + "BOOLEAN", + "CATEGORICAL" + ] + }, + "public.span_type": { + "name": "span_type", + "schema": "public", + "values": [ + "DEFAULT", + "LLM", + "PIPELINE", + "EXECUTOR", + "EVALUATOR", + "EVALUATION" + ] + }, + "public.trace_type": { + "name": "trace_type", + "schema": "public", + "values": [ + "DEFAULT", + "EVENT", + "EVALUATION" + ] + }, + "public.workspace_role": { + "name": "workspace_role", + "schema": "public", + "values": [ + "member", + "owner" + ] + } + }, + "schemas": {}, + "sequences": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/frontend/lib/db/migrations/meta/_journal.json b/frontend/lib/db/migrations/meta/_journal.json index c016cb58..1e320417 100644 --- a/frontend/lib/db/migrations/meta/_journal.json +++ b/frontend/lib/db/migrations/meta/_journal.json @@ -19,8 +19,15 @@ { "idx": 2, "version": "7", - "when": 1730581897701, - "tag": "0002_next_tusk", + "when": 1730608599324, + "tag": "0002_cold_romulus", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1730701646174, + "tag": "0003_cultured_tinkerer", "breakpoints": true } ] diff --git a/frontend/lib/db/relations.ts b/frontend/lib/db/relations.ts index 9d94ba93..26a52b71 100644 --- a/frontend/lib/db/relations.ts +++ b/frontend/lib/db/relations.ts @@ -1,5 +1,5 @@ import { relations } from "drizzle-orm/relations"; -import { pipelines, targetPipelineVersions, pipelineVersions, projects, traces, evaluations, evaluationResults, spans, eventTemplates, events, labelingQueues, providerApiKeys, workspaces, workspaceUsage, evaluationScores, labelClassesForPath, users, apiKeys, datasets, datasetDatapoints, labelingQueueData, membersOfWorkspaces, projectApiKeys, subscriptionTiers, userSubscriptionInfo, labels, labelClasses } from "./schema"; +import { pipelines, targetPipelineVersions, pipelineVersions, projects, traces, evaluations, evaluationResults, eventTemplates, events, labelingQueues, providerApiKeys, workspaces, workspaceUsage, evaluationScores, labelClassesForPath, users, apiKeys, datasets, datasetDatapoints, labelingQueueData, membersOfWorkspaces, projectApiKeys, subscriptionTiers, userSubscriptionInfo, labelClasses, labels, spans } from "./schema"; export const targetPipelineVersionsRelations = relations(targetPipelineVersions, ({one}) => ({ pipeline: one(pipelines, { @@ -47,6 +47,7 @@ export const projectsRelations = relations(projects, ({one, many}) => ({ }), projectApiKeys: many(projectApiKeys), labelClasses: many(labelClasses), + spans: many(spans), })); export const evaluationResultsRelations = relations(evaluationResults, ({one, many}) => ({ @@ -65,14 +66,6 @@ export const evaluationsRelations = relations(evaluations, ({one, many}) => ({ }), })); -export const spansRelations = relations(spans, ({one, many}) => ({ - trace: one(traces, { - fields: [spans.traceId], - references: [traces.id] - }), - labels: many(labels), -})); - export const eventsRelations = relations(events, ({one}) => ({ eventTemplate: one(eventTemplates, { fields: [events.templateId], @@ -199,10 +192,6 @@ export const userSubscriptionInfoRelations = relations(userSubscriptionInfo, ({o })); export const labelsRelations = relations(labels, ({one}) => ({ - span: one(spans, { - fields: [labels.spanId], - references: [spans.spanId] - }), labelClass: one(labelClasses, { fields: [labels.classId], references: [labelClasses.id] @@ -216,3 +205,14 @@ export const labelClassesRelations = relations(labelClasses, ({one, many}) => ({ references: [projects.id] }), })); + +export const spansRelations = relations(spans, ({one}) => ({ + trace: one(traces, { + fields: [spans.traceId], + references: [traces.id] + }), + project: one(projects, { + fields: [spans.projectId], + references: [projects.id] + }), +})); diff --git a/frontend/lib/db/schema.ts b/frontend/lib/db/schema.ts index 5bbbf606..0178d92f 100644 --- a/frontend/lib/db/schema.ts +++ b/frontend/lib/db/schema.ts @@ -1,4 +1,4 @@ -import { pgTable, foreignKey, unique, uuid, timestamp, index, text, jsonb, bigint, boolean, doublePrecision, integer, pgEnum } from "drizzle-orm/pg-core"; +import { pgTable, foreignKey, unique, uuid, timestamp, index, text, jsonb, bigint, boolean, doublePrecision, integer, primaryKey, pgEnum } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm"; export const eventSource = pgEnum("event_source", ['AUTO', 'MANUAL', 'CODE']); @@ -87,33 +87,6 @@ export const evaluationResults = pgTable("evaluation_results", { }).onUpdate("cascade").onDelete("cascade"), })); -export const spans = pgTable("spans", { - spanId: uuid("span_id").primaryKey().notNull(), - createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), - parentSpanId: uuid("parent_span_id"), - name: text().notNull(), - attributes: jsonb(), - input: jsonb(), - output: jsonb(), - spanType: spanType("span_type").notNull(), - startTime: timestamp("start_time", { withTimezone: true, mode: 'string' }).notNull(), - endTime: timestamp("end_time", { withTimezone: true, mode: 'string' }).notNull(), - traceId: uuid("trace_id").notNull(), - version: text().notNull(), - inputPreview: text("input_preview"), - outputPreview: text("output_preview"), -}, -(table) => ({ - spanPathIdx: index("span_path_idx").using("btree", sql`(attributes -> 'lmnr.span.path'::text)`), - startTimeEndTimeIdx: index("spans_start_time_end_time_idx").using("btree", table.startTime.asc().nullsLast(), table.endTime.asc().nullsLast()), - traceIdIdx: index("spans_trace_id_idx").using("btree", table.traceId.asc().nullsLast()), - newSpansTraceIdFkey: foreignKey({ - columns: [table.traceId], - foreignColumns: [traces.id], - name: "new_spans_trace_id_fkey" - }).onUpdate("cascade").onDelete("cascade"), -})); - export const events = pgTable("events", { id: uuid().defaultRandom().primaryKey().notNull(), createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), @@ -339,8 +312,8 @@ export const labelingQueueData = pgTable("labeling_queue_data", { id: uuid().defaultRandom().primaryKey().notNull(), createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), queueId: uuid("queue_id").defaultRandom().notNull(), - data: jsonb().notNull(), action: jsonb().notNull(), + spanId: uuid("span_id").notNull(), }, (table) => ({ labellingQueueDataQueueIdFkey: foreignKey({ @@ -502,11 +475,6 @@ export const labels = pgTable("labels", { reasoning: text(), }, (table) => ({ - traceTagsSpanIdFkey: foreignKey({ - columns: [table.spanId], - foreignColumns: [spans.spanId], - name: "trace_tags_span_id_fkey" - }).onUpdate("cascade").onDelete("cascade"), traceTagsTypeIdFkey: foreignKey({ columns: [table.classId], foreignColumns: [labelClasses.id], @@ -533,3 +501,39 @@ export const labelClasses = pgTable("label_classes", { name: "label_classes_project_id_fkey" }).onUpdate("cascade").onDelete("cascade"), })); + +export const spans = pgTable("spans", { + spanId: uuid("span_id").notNull(), + createdAt: timestamp("created_at", { withTimezone: true, mode: 'string' }).defaultNow().notNull(), + parentSpanId: uuid("parent_span_id"), + name: text().notNull(), + attributes: jsonb(), + input: jsonb(), + output: jsonb(), + spanType: spanType("span_type").notNull(), + startTime: timestamp("start_time", { withTimezone: true, mode: 'string' }).notNull(), + endTime: timestamp("end_time", { withTimezone: true, mode: 'string' }).notNull(), + traceId: uuid("trace_id").notNull(), + version: text().notNull(), + inputPreview: text("input_preview"), + outputPreview: text("output_preview"), + projectId: uuid("project_id").notNull(), +}, +(table) => ({ + spanPathIdx: index("span_path_idx").using("btree", sql`(attributes -> 'lmnr.span.path'::text)`), + projectIdIdx: index("spans_project_id_idx").using("btree", table.projectId.asc().nullsLast()), + startTimeEndTimeIdx: index("spans_start_time_end_time_idx").using("btree", table.startTime.asc().nullsLast(), table.endTime.asc().nullsLast()), + traceIdIdx: index("spans_trace_id_idx").using("btree", table.traceId.asc().nullsLast()), + newSpansTraceIdFkey: foreignKey({ + columns: [table.traceId], + foreignColumns: [traces.id], + name: "new_spans_trace_id_fkey" + }).onUpdate("cascade").onDelete("cascade"), + spansProjectIdFkey: foreignKey({ + columns: [table.projectId], + foreignColumns: [projects.id], + name: "spans_project_id_fkey" + }).onUpdate("cascade"), + spansPkey: primaryKey({ columns: [table.spanId, table.projectId], name: "spans_pkey"}), + uniqueSpanIdProjectId: unique("unique_span_id_project_id").on(table.spanId, table.projectId), +}));