From 4e865463119329876d8a5a3aef9a18d2ffeb86d5 Mon Sep 17 00:00:00 2001 From: Sean O'Connor Date: Sat, 21 Mar 2026 20:03:33 -0400 Subject: [PATCH] Add identifier column to plugins table for cleaner plugin lookup - Added 'identifier' column (unique) for machine-readable plugin ID - 'name' now used for display name only - Updated trial-execution to look up by identifier first, then name - Added migration script for existing databases --- drizzle/0000_old_tattoo.sql | 553 ++++ drizzle/meta/0000_snapshot.json | 3908 ++++++++++++++++++++++++ drizzle/meta/_journal.json | 13 + scripts/migrate-add-identifier.ts | 31 + scripts/seed-dev.ts | 1 + src/server/db/schema.ts | 1 + src/server/services/trial-execution.ts | 44 +- 7 files changed, 4539 insertions(+), 12 deletions(-) create mode 100644 drizzle/0000_old_tattoo.sql create mode 100644 drizzle/meta/0000_snapshot.json create mode 100644 drizzle/meta/_journal.json create mode 100644 scripts/migrate-add-identifier.ts diff --git a/drizzle/0000_old_tattoo.sql b/drizzle/0000_old_tattoo.sql new file mode 100644 index 0000000..a160b1c --- /dev/null +++ b/drizzle/0000_old_tattoo.sql @@ -0,0 +1,553 @@ +CREATE TYPE "public"."block_category" AS ENUM('wizard', 'robot', 'control', 'sensor', 'logic', 'event');--> statement-breakpoint +CREATE TYPE "public"."block_shape" AS ENUM('action', 'control', 'value', 'boolean', 'hat', 'cap');--> statement-breakpoint +CREATE TYPE "public"."communication_protocol" AS ENUM('rest', 'ros2', 'custom');--> statement-breakpoint +CREATE TYPE "public"."experiment_status" AS ENUM('draft', 'testing', 'ready', 'deprecated');--> statement-breakpoint +CREATE TYPE "public"."export_status" AS ENUM('pending', 'processing', 'completed', 'failed');--> statement-breakpoint +CREATE TYPE "public"."media_type" AS ENUM('video', 'audio', 'image');--> statement-breakpoint +CREATE TYPE "public"."plugin_status" AS ENUM('active', 'deprecated', 'disabled');--> statement-breakpoint +CREATE TYPE "public"."step_type" AS ENUM('wizard', 'robot', 'parallel', 'conditional');--> statement-breakpoint +CREATE TYPE "public"."study_member_role" AS ENUM('owner', 'researcher', 'wizard', 'observer');--> statement-breakpoint +CREATE TYPE "public"."study_status" AS ENUM('draft', 'active', 'completed', 'archived');--> statement-breakpoint +CREATE TYPE "public"."system_role" AS ENUM('administrator', 'researcher', 'wizard', 'observer');--> statement-breakpoint +CREATE TYPE "public"."trial_status" AS ENUM('scheduled', 'in_progress', 'completed', 'aborted', 'failed');--> statement-breakpoint +CREATE TYPE "public"."trust_level" AS ENUM('official', 'verified', 'community');--> statement-breakpoint +CREATE TABLE "hs_account" ( + "user_id" uuid NOT NULL, + "type" varchar(255) NOT NULL, + "provider" varchar(255) NOT NULL, + "provider_account_id" varchar(255) NOT NULL, + "refresh_token" text, + "access_token" text, + "expires_at" integer, + "token_type" varchar(255), + "scope" varchar(255), + "id_token" text, + "session_state" varchar(255), + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_account_provider_provider_account_id_pk" PRIMARY KEY("provider","provider_account_id") +); +--> statement-breakpoint +CREATE TABLE "hs_action" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "step_id" uuid NOT NULL, + "name" varchar(255) NOT NULL, + "description" text, + "type" varchar(100) NOT NULL, + "order_index" integer NOT NULL, + "parameters" jsonb DEFAULT '{}'::jsonb, + "validation_schema" jsonb, + "timeout" integer, + "retry_count" integer DEFAULT 0 NOT NULL, + "source_kind" varchar(20), + "plugin_id" varchar(255), + "plugin_version" varchar(50), + "robot_id" varchar(255), + "base_action_id" varchar(255), + "category" varchar(50), + "transport" varchar(20), + "ros2_config" jsonb, + "rest_config" jsonb, + "retryable" boolean, + "parameter_schema_raw" jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_action_step_id_order_index_unique" UNIQUE("step_id","order_index") +); +--> statement-breakpoint +CREATE TABLE "hs_activity_log" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid, + "user_id" uuid, + "action" varchar(100) NOT NULL, + "resource_type" varchar(50), + "resource_id" uuid, + "description" text, + "ip_address" "inet", + "user_agent" text, + "metadata" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_annotation" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "trial_id" uuid NOT NULL, + "annotator_id" uuid NOT NULL, + "timestamp_start" timestamp with time zone NOT NULL, + "timestamp_end" timestamp with time zone, + "category" varchar(100), + "label" varchar(100), + "description" text, + "tags" jsonb DEFAULT '[]'::jsonb, + "metadata" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_attachment" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "resource_type" varchar(50) NOT NULL, + "resource_id" uuid NOT NULL, + "file_name" varchar(255) NOT NULL, + "file_size" bigint NOT NULL, + "file_path" text NOT NULL, + "content_type" varchar(100), + "description" text, + "uploaded_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_audit_log" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "user_id" uuid, + "action" varchar(100) NOT NULL, + "resource_type" varchar(50), + "resource_id" uuid, + "changes" jsonb DEFAULT '{}'::jsonb, + "ip_address" "inet", + "user_agent" text, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_block_registry" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "block_type" varchar(100) NOT NULL, + "plugin_id" uuid, + "shape" "block_shape" NOT NULL, + "category" "block_category" NOT NULL, + "display_name" varchar(255) NOT NULL, + "description" text, + "icon" varchar(100), + "color" varchar(50), + "config" jsonb NOT NULL, + "parameter_schema" jsonb NOT NULL, + "execution_handler" varchar(100), + "timeout" integer, + "retry_policy" jsonb, + "requires_connection" boolean DEFAULT false, + "preview_mode" boolean DEFAULT true, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_block_registry_block_type_plugin_id_unique" UNIQUE("block_type","plugin_id") +); +--> statement-breakpoint +CREATE TABLE "hs_comment" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "parent_id" uuid, + "resource_type" varchar(50) NOT NULL, + "resource_id" uuid NOT NULL, + "author_id" uuid NOT NULL, + "content" text NOT NULL, + "metadata" jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_consent_form" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "version" integer DEFAULT 1 NOT NULL, + "title" varchar(255) NOT NULL, + "content" text NOT NULL, + "active" boolean DEFAULT true NOT NULL, + "created_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "storage_path" text, + CONSTRAINT "hs_consent_form_study_id_version_unique" UNIQUE("study_id","version") +); +--> statement-breakpoint +CREATE TABLE "hs_experiment" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "name" varchar(255) NOT NULL, + "description" text, + "version" integer DEFAULT 1 NOT NULL, + "robot_id" uuid, + "status" "experiment_status" DEFAULT 'draft' NOT NULL, + "estimated_duration" integer, + "created_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "metadata" jsonb DEFAULT '{}'::jsonb, + "visual_design" jsonb, + "execution_graph" jsonb, + "plugin_dependencies" text[], + "integrity_hash" varchar(128), + "deleted_at" timestamp with time zone, + CONSTRAINT "hs_experiment_study_id_name_version_unique" UNIQUE("study_id","name","version") +); +--> statement-breakpoint +CREATE TABLE "hs_export_job" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "requested_by" uuid NOT NULL, + "export_type" varchar(50) NOT NULL, + "format" varchar(20) NOT NULL, + "filters" jsonb DEFAULT '{}'::jsonb, + "status" "export_status" DEFAULT 'pending' NOT NULL, + "storage_path" text, + "expires_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "completed_at" timestamp with time zone, + "error_message" text +); +--> statement-breakpoint +CREATE TABLE "hs_media_capture" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "trial_id" uuid NOT NULL, + "media_type" "media_type", + "storage_path" text NOT NULL, + "file_size" bigint, + "duration" integer, + "format" varchar(20), + "resolution" varchar(20), + "start_timestamp" timestamp with time zone, + "end_timestamp" timestamp with time zone, + "metadata" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_participant_consent" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "participant_id" uuid NOT NULL, + "consent_form_id" uuid NOT NULL, + "signed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "signature_data" text, + "ip_address" "inet", + "storage_path" text, + CONSTRAINT "hs_participant_consent_participant_id_consent_form_id_unique" UNIQUE("participant_id","consent_form_id") +); +--> statement-breakpoint +CREATE TABLE "hs_participant_document" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "participant_id" uuid NOT NULL, + "name" varchar(255) NOT NULL, + "type" varchar(100), + "storage_path" text NOT NULL, + "file_size" integer, + "uploaded_by" uuid, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_participant" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "participant_code" varchar(50) NOT NULL, + "email" varchar(255), + "name" varchar(255), + "demographics" jsonb DEFAULT '{}'::jsonb, + "consent_given" boolean DEFAULT false NOT NULL, + "consent_date" timestamp with time zone, + "notes" text, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_participant_study_id_participant_code_unique" UNIQUE("study_id","participant_code") +); +--> statement-breakpoint +CREATE TABLE "hs_permission" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar(100) NOT NULL, + "description" text, + "resource" varchar(50) NOT NULL, + "action" varchar(50) NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_permission_name_unique" UNIQUE("name") +); +--> statement-breakpoint +CREATE TABLE "hs_plugin_repository" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar(255) NOT NULL, + "url" text NOT NULL, + "description" text, + "trust_level" "trust_level" DEFAULT 'community' NOT NULL, + "is_enabled" boolean DEFAULT true NOT NULL, + "is_official" boolean DEFAULT false NOT NULL, + "last_sync_at" timestamp with time zone, + "sync_status" varchar(50) DEFAULT 'pending', + "sync_error" text, + "metadata" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "created_by" uuid NOT NULL, + CONSTRAINT "hs_plugin_repository_url_unique" UNIQUE("url") +); +--> statement-breakpoint +CREATE TABLE "hs_plugin" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "robot_id" uuid, + "identifier" varchar(100) NOT NULL, + "name" varchar(255) NOT NULL, + "version" varchar(50) NOT NULL, + "description" text, + "author" varchar(255), + "repository_url" text, + "trust_level" "trust_level", + "status" "plugin_status" DEFAULT 'active' NOT NULL, + "configuration_schema" jsonb, + "action_definitions" jsonb DEFAULT '[]'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "metadata" jsonb DEFAULT '{}'::jsonb, + CONSTRAINT "hs_plugin_identifier_unique" UNIQUE("identifier"), + CONSTRAINT "hs_plugin_name_version_unique" UNIQUE("name","version") +); +--> statement-breakpoint +CREATE TABLE "hs_robot_plugin" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar(255) NOT NULL, + "version" varchar(50) NOT NULL, + "manufacturer" varchar(255), + "description" text, + "robot_id" uuid, + "communication_protocol" "communication_protocol", + "status" "plugin_status" DEFAULT 'active' NOT NULL, + "config_schema" jsonb, + "capabilities" jsonb DEFAULT '[]'::jsonb, + "trust_level" "trust_level" DEFAULT 'community' NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_robot" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar(255) NOT NULL, + "manufacturer" varchar(255), + "model" varchar(255), + "description" text, + "capabilities" jsonb DEFAULT '[]'::jsonb, + "communication_protocol" "communication_protocol", + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_role_permission" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "role" "system_role" NOT NULL, + "permission_id" uuid NOT NULL, + CONSTRAINT "hs_role_permission_role_permission_id_unique" UNIQUE("role","permission_id") +); +--> statement-breakpoint +CREATE TABLE "hs_sensor_data" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "trial_id" uuid NOT NULL, + "sensor_type" varchar(50) NOT NULL, + "timestamp" timestamp with time zone NOT NULL, + "data" jsonb NOT NULL, + "robot_state" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL +); +--> statement-breakpoint +CREATE TABLE "hs_session" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "session_token" varchar(255) NOT NULL, + "user_id" uuid NOT NULL, + "expires" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_session_session_token_unique" UNIQUE("session_token") +); +--> statement-breakpoint +CREATE TABLE "hs_shared_resource" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "resource_type" varchar(50) NOT NULL, + "resource_id" uuid NOT NULL, + "shared_by" uuid NOT NULL, + "share_token" varchar(255), + "permissions" jsonb DEFAULT '["read"]'::jsonb, + "expires_at" timestamp with time zone, + "access_count" integer DEFAULT 0 NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_shared_resource_share_token_unique" UNIQUE("share_token") +); +--> statement-breakpoint +CREATE TABLE "hs_step" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "experiment_id" uuid NOT NULL, + "name" varchar(255) NOT NULL, + "description" text, + "type" "step_type" NOT NULL, + "order_index" integer NOT NULL, + "duration_estimate" integer, + "required" boolean DEFAULT true NOT NULL, + "conditions" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_step_experiment_id_order_index_unique" UNIQUE("experiment_id","order_index") +); +--> statement-breakpoint +CREATE TABLE "hs_study" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "name" varchar(255) NOT NULL, + "description" text, + "institution" varchar(255), + "irb_protocol" varchar(100), + "status" "study_status" DEFAULT 'draft' NOT NULL, + "created_by" uuid NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "metadata" jsonb DEFAULT '{}'::jsonb, + "settings" jsonb DEFAULT '{}'::jsonb, + "deleted_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE "hs_study_member" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "user_id" uuid NOT NULL, + "role" "study_member_role" NOT NULL, + "permissions" jsonb DEFAULT '[]'::jsonb, + "joined_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "invited_by" uuid, + CONSTRAINT "hs_study_member_study_id_user_id_unique" UNIQUE("study_id","user_id") +); +--> statement-breakpoint +CREATE TABLE "hs_study_plugin" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "study_id" uuid NOT NULL, + "plugin_id" uuid NOT NULL, + "configuration" jsonb DEFAULT '{}'::jsonb, + "installed_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "installed_by" uuid NOT NULL, + CONSTRAINT "hs_study_plugin_study_id_plugin_id_unique" UNIQUE("study_id","plugin_id") +); +--> statement-breakpoint +CREATE TABLE "hs_system_setting" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "key" varchar(100) NOT NULL, + "value" jsonb NOT NULL, + "description" text, + "updated_by" uuid, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_system_setting_key_unique" UNIQUE("key") +); +--> statement-breakpoint +CREATE TABLE "hs_trial_event" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "trial_id" uuid NOT NULL, + "event_type" varchar(50) NOT NULL, + "action_id" uuid, + "timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "data" jsonb DEFAULT '{}'::jsonb, + "created_by" uuid +); +--> statement-breakpoint +CREATE TABLE "hs_trial" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "experiment_id" uuid NOT NULL, + "participant_id" uuid, + "wizard_id" uuid, + "session_number" integer DEFAULT 1 NOT NULL, + "status" "trial_status" DEFAULT 'scheduled' NOT NULL, + "scheduled_at" timestamp with time zone, + "started_at" timestamp with time zone, + "completed_at" timestamp with time zone, + "duration" integer, + "notes" text, + "parameters" jsonb DEFAULT '{}'::jsonb, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "metadata" jsonb DEFAULT '{}'::jsonb +); +--> statement-breakpoint +CREATE TABLE "hs_user_system_role" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "user_id" uuid NOT NULL, + "role" "system_role" NOT NULL, + "granted_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "granted_by" uuid, + CONSTRAINT "hs_user_system_role_user_id_role_unique" UNIQUE("user_id","role") +); +--> statement-breakpoint +CREATE TABLE "hs_user" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "email" varchar(255) NOT NULL, + "email_verified" timestamp with time zone, + "name" varchar(255), + "image" text, + "password" varchar(255), + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "updated_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "deleted_at" timestamp with time zone, + CONSTRAINT "hs_user_email_unique" UNIQUE("email") +); +--> statement-breakpoint +CREATE TABLE "hs_verification_token" ( + "identifier" varchar(255) NOT NULL, + "token" varchar(255) NOT NULL, + "expires" timestamp with time zone NOT NULL, + "created_at" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + CONSTRAINT "hs_verification_token_identifier_token_pk" PRIMARY KEY("identifier","token"), + CONSTRAINT "hs_verification_token_token_unique" UNIQUE("token") +); +--> statement-breakpoint +CREATE TABLE "hs_wizard_intervention" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "trial_id" uuid NOT NULL, + "wizard_id" uuid NOT NULL, + "intervention_type" varchar(100) NOT NULL, + "description" text, + "timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + "parameters" jsonb DEFAULT '{}'::jsonb, + "reason" text +); +--> statement-breakpoint +ALTER TABLE "hs_account" ADD CONSTRAINT "hs_account_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_action" ADD CONSTRAINT "hs_action_step_id_hs_step_id_fk" FOREIGN KEY ("step_id") REFERENCES "public"."hs_step"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_activity_log" ADD CONSTRAINT "hs_activity_log_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_activity_log" ADD CONSTRAINT "hs_activity_log_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_annotation" ADD CONSTRAINT "hs_annotation_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_annotation" ADD CONSTRAINT "hs_annotation_annotator_id_hs_user_id_fk" FOREIGN KEY ("annotator_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_attachment" ADD CONSTRAINT "hs_attachment_uploaded_by_hs_user_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_audit_log" ADD CONSTRAINT "hs_audit_log_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_block_registry" ADD CONSTRAINT "hs_block_registry_plugin_id_hs_robot_plugin_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."hs_robot_plugin"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_comment" ADD CONSTRAINT "hs_comment_author_id_hs_user_id_fk" FOREIGN KEY ("author_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_consent_form" ADD CONSTRAINT "hs_consent_form_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_consent_form" ADD CONSTRAINT "hs_consent_form_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_experiment" ADD CONSTRAINT "hs_experiment_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_export_job" ADD CONSTRAINT "hs_export_job_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_export_job" ADD CONSTRAINT "hs_export_job_requested_by_hs_user_id_fk" FOREIGN KEY ("requested_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_media_capture" ADD CONSTRAINT "hs_media_capture_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_participant_consent" ADD CONSTRAINT "hs_participant_consent_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_participant_consent" ADD CONSTRAINT "hs_participant_consent_consent_form_id_hs_consent_form_id_fk" FOREIGN KEY ("consent_form_id") REFERENCES "public"."hs_consent_form"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_participant_document" ADD CONSTRAINT "hs_participant_document_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_participant_document" ADD CONSTRAINT "hs_participant_document_uploaded_by_hs_user_id_fk" FOREIGN KEY ("uploaded_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_participant" ADD CONSTRAINT "hs_participant_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_plugin_repository" ADD CONSTRAINT "hs_plugin_repository_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_plugin" ADD CONSTRAINT "hs_plugin_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_robot_plugin" ADD CONSTRAINT "hs_robot_plugin_robot_id_hs_robot_id_fk" FOREIGN KEY ("robot_id") REFERENCES "public"."hs_robot"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_role_permission" ADD CONSTRAINT "hs_role_permission_permission_id_hs_permission_id_fk" FOREIGN KEY ("permission_id") REFERENCES "public"."hs_permission"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_sensor_data" ADD CONSTRAINT "hs_sensor_data_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_session" ADD CONSTRAINT "hs_session_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_shared_resource" ADD CONSTRAINT "hs_shared_resource_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_shared_resource" ADD CONSTRAINT "hs_shared_resource_shared_by_hs_user_id_fk" FOREIGN KEY ("shared_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_step" ADD CONSTRAINT "hs_step_experiment_id_hs_experiment_id_fk" FOREIGN KEY ("experiment_id") REFERENCES "public"."hs_experiment"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study" ADD CONSTRAINT "hs_study_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_member" ADD CONSTRAINT "hs_study_member_invited_by_hs_user_id_fk" FOREIGN KEY ("invited_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_study_id_hs_study_id_fk" FOREIGN KEY ("study_id") REFERENCES "public"."hs_study"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_plugin_id_hs_plugin_id_fk" FOREIGN KEY ("plugin_id") REFERENCES "public"."hs_plugin"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_study_plugin" ADD CONSTRAINT "hs_study_plugin_installed_by_hs_user_id_fk" FOREIGN KEY ("installed_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_system_setting" ADD CONSTRAINT "hs_system_setting_updated_by_hs_user_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_action_id_hs_action_id_fk" FOREIGN KEY ("action_id") REFERENCES "public"."hs_action"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial_event" ADD CONSTRAINT "hs_trial_event_created_by_hs_user_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_experiment_id_hs_experiment_id_fk" FOREIGN KEY ("experiment_id") REFERENCES "public"."hs_experiment"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_participant_id_hs_participant_id_fk" FOREIGN KEY ("participant_id") REFERENCES "public"."hs_participant"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_trial" ADD CONSTRAINT "hs_trial_wizard_id_hs_user_id_fk" FOREIGN KEY ("wizard_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_user_system_role" ADD CONSTRAINT "hs_user_system_role_user_id_hs_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."hs_user"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_user_system_role" ADD CONSTRAINT "hs_user_system_role_granted_by_hs_user_id_fk" FOREIGN KEY ("granted_by") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_wizard_intervention" ADD CONSTRAINT "hs_wizard_intervention_trial_id_hs_trial_id_fk" FOREIGN KEY ("trial_id") REFERENCES "public"."hs_trial"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "hs_wizard_intervention" ADD CONSTRAINT "hs_wizard_intervention_wizard_id_hs_user_id_fk" FOREIGN KEY ("wizard_id") REFERENCES "public"."hs_user"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "account_user_id_idx" ON "hs_account" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "activity_logs_study_created_idx" ON "hs_activity_log" USING btree ("study_id","created_at");--> statement-breakpoint +CREATE INDEX "audit_logs_created_idx" ON "hs_audit_log" USING btree ("created_at");--> statement-breakpoint +CREATE INDEX "block_registry_category_idx" ON "hs_block_registry" USING btree ("category");--> statement-breakpoint +CREATE INDEX "experiment_visual_design_idx" ON "hs_experiment" USING gin ("visual_design");--> statement-breakpoint +CREATE INDEX "participant_document_participant_idx" ON "hs_participant_document" USING btree ("participant_id");--> statement-breakpoint +CREATE INDEX "sensor_data_trial_timestamp_idx" ON "hs_sensor_data" USING btree ("trial_id","timestamp");--> statement-breakpoint +CREATE INDEX "session_user_id_idx" ON "hs_session" USING btree ("user_id");--> statement-breakpoint +CREATE INDEX "trial_events_trial_timestamp_idx" ON "hs_trial_event" USING btree ("trial_id","timestamp"); \ No newline at end of file diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..6872776 --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,3908 @@ +{ + "id": "f8c63e57-ff30-4fe1-b512-fc54f99fd5b1", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.hs_account": { + "name": "hs_account", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "provider_account_id": { + "name": "provider_account_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "token_type": { + "name": "token_type", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "session_state": { + "name": "session_state", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "account_user_id_idx": { + "name": "account_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_account_user_id_hs_user_id_fk": { + "name": "hs_account_user_id_hs_user_id_fk", + "tableFrom": "hs_account", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "hs_account_provider_provider_account_id_pk": { + "name": "hs_account_provider_provider_account_id_pk", + "columns": [ + "provider", + "provider_account_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_action": { + "name": "hs_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "step_id": { + "name": "step_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "order_index": { + "name": "order_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "validation_schema": { + "name": "validation_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "timeout": { + "name": "timeout", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "retry_count": { + "name": "retry_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "source_kind": { + "name": "source_kind", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "plugin_id": { + "name": "plugin_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "plugin_version": { + "name": "plugin_version", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "robot_id": { + "name": "robot_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "base_action_id": { + "name": "base_action_id", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "transport": { + "name": "transport", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "ros2_config": { + "name": "ros2_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rest_config": { + "name": "rest_config", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "retryable": { + "name": "retryable", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "parameter_schema_raw": { + "name": "parameter_schema_raw", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_action_step_id_hs_step_id_fk": { + "name": "hs_action_step_id_hs_step_id_fk", + "tableFrom": "hs_action", + "tableTo": "hs_step", + "columnsFrom": [ + "step_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_action_step_id_order_index_unique": { + "name": "hs_action_step_id_order_index_unique", + "nullsNotDistinct": false, + "columns": [ + "step_id", + "order_index" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_activity_log": { + "name": "hs_activity_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "inet", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "activity_logs_study_created_idx": { + "name": "activity_logs_study_created_idx", + "columns": [ + { + "expression": "study_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_activity_log_study_id_hs_study_id_fk": { + "name": "hs_activity_log_study_id_hs_study_id_fk", + "tableFrom": "hs_activity_log", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_activity_log_user_id_hs_user_id_fk": { + "name": "hs_activity_log_user_id_hs_user_id_fk", + "tableFrom": "hs_activity_log", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_annotation": { + "name": "hs_annotation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trial_id": { + "name": "trial_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "annotator_id": { + "name": "annotator_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "timestamp_start": { + "name": "timestamp_start", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "timestamp_end": { + "name": "timestamp_end", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "label": { + "name": "label", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_annotation_trial_id_hs_trial_id_fk": { + "name": "hs_annotation_trial_id_hs_trial_id_fk", + "tableFrom": "hs_annotation", + "tableTo": "hs_trial", + "columnsFrom": [ + "trial_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_annotation_annotator_id_hs_user_id_fk": { + "name": "hs_annotation_annotator_id_hs_user_id_fk", + "tableFrom": "hs_annotation", + "tableTo": "hs_user", + "columnsFrom": [ + "annotator_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_attachment": { + "name": "hs_attachment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "resource_type": { + "name": "resource_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "file_path": { + "name": "file_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_type": { + "name": "content_type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_attachment_uploaded_by_hs_user_id_fk": { + "name": "hs_attachment_uploaded_by_hs_user_id_fk", + "tableFrom": "hs_attachment", + "tableTo": "hs_user", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_audit_log": { + "name": "hs_audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "action": { + "name": "action", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "changes": { + "name": "changes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "ip_address": { + "name": "ip_address", + "type": "inet", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "audit_logs_created_idx": { + "name": "audit_logs_created_idx", + "columns": [ + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_audit_log_user_id_hs_user_id_fk": { + "name": "hs_audit_log_user_id_hs_user_id_fk", + "tableFrom": "hs_audit_log", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_block_registry": { + "name": "hs_block_registry", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "block_type": { + "name": "block_type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "plugin_id": { + "name": "plugin_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "shape": { + "name": "shape", + "type": "block_shape", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "block_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "icon": { + "name": "icon", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false + }, + "config": { + "name": "config", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "parameter_schema": { + "name": "parameter_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "execution_handler": { + "name": "execution_handler", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "timeout": { + "name": "timeout", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "retry_policy": { + "name": "retry_policy", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "requires_connection": { + "name": "requires_connection", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "preview_mode": { + "name": "preview_mode", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "block_registry_category_idx": { + "name": "block_registry_category_idx", + "columns": [ + { + "expression": "category", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_block_registry_plugin_id_hs_robot_plugin_id_fk": { + "name": "hs_block_registry_plugin_id_hs_robot_plugin_id_fk", + "tableFrom": "hs_block_registry", + "tableTo": "hs_robot_plugin", + "columnsFrom": [ + "plugin_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_block_registry_block_type_plugin_id_unique": { + "name": "hs_block_registry_block_type_plugin_id_unique", + "nullsNotDistinct": false, + "columns": [ + "block_type", + "plugin_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_comment": { + "name": "hs_comment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "parent_id": { + "name": "parent_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "resource_type": { + "name": "resource_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_comment_author_id_hs_user_id_fk": { + "name": "hs_comment_author_id_hs_user_id_fk", + "tableFrom": "hs_comment", + "tableTo": "hs_user", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_consent_form": { + "name": "hs_consent_form", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "title": { + "name": "title", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_consent_form_study_id_hs_study_id_fk": { + "name": "hs_consent_form_study_id_hs_study_id_fk", + "tableFrom": "hs_consent_form", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_consent_form_created_by_hs_user_id_fk": { + "name": "hs_consent_form_created_by_hs_user_id_fk", + "tableFrom": "hs_consent_form", + "tableTo": "hs_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_consent_form_study_id_version_unique": { + "name": "hs_consent_form_study_id_version_unique", + "nullsNotDistinct": false, + "columns": [ + "study_id", + "version" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_experiment": { + "name": "hs_experiment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "robot_id": { + "name": "robot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "experiment_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "estimated_duration": { + "name": "estimated_duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "visual_design": { + "name": "visual_design", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "execution_graph": { + "name": "execution_graph", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "plugin_dependencies": { + "name": "plugin_dependencies", + "type": "text[]", + "primaryKey": false, + "notNull": false + }, + "integrity_hash": { + "name": "integrity_hash", + "type": "varchar(128)", + "primaryKey": false, + "notNull": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "experiment_visual_design_idx": { + "name": "experiment_visual_design_idx", + "columns": [ + { + "expression": "visual_design", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "gin", + "with": {} + } + }, + "foreignKeys": { + "hs_experiment_study_id_hs_study_id_fk": { + "name": "hs_experiment_study_id_hs_study_id_fk", + "tableFrom": "hs_experiment", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_experiment_robot_id_hs_robot_id_fk": { + "name": "hs_experiment_robot_id_hs_robot_id_fk", + "tableFrom": "hs_experiment", + "tableTo": "hs_robot", + "columnsFrom": [ + "robot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hs_experiment_created_by_hs_user_id_fk": { + "name": "hs_experiment_created_by_hs_user_id_fk", + "tableFrom": "hs_experiment", + "tableTo": "hs_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_experiment_study_id_name_version_unique": { + "name": "hs_experiment_study_id_name_version_unique", + "nullsNotDistinct": false, + "columns": [ + "study_id", + "name", + "version" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_export_job": { + "name": "hs_export_job", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_by": { + "name": "requested_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "export_type": { + "name": "export_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "varchar(20)", + "primaryKey": false, + "notNull": true + }, + "filters": { + "name": "filters", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "status": { + "name": "status", + "type": "export_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_export_job_study_id_hs_study_id_fk": { + "name": "hs_export_job_study_id_hs_study_id_fk", + "tableFrom": "hs_export_job", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_export_job_requested_by_hs_user_id_fk": { + "name": "hs_export_job_requested_by_hs_user_id_fk", + "tableFrom": "hs_export_job", + "tableTo": "hs_user", + "columnsFrom": [ + "requested_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_media_capture": { + "name": "hs_media_capture", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trial_id": { + "name": "trial_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "media_type": { + "name": "media_type", + "type": "media_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "format": { + "name": "format", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "resolution": { + "name": "resolution", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false + }, + "start_timestamp": { + "name": "start_timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "end_timestamp": { + "name": "end_timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_media_capture_trial_id_hs_trial_id_fk": { + "name": "hs_media_capture_trial_id_hs_trial_id_fk", + "tableFrom": "hs_media_capture", + "tableTo": "hs_trial", + "columnsFrom": [ + "trial_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_participant_consent": { + "name": "hs_participant_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "participant_id": { + "name": "participant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "consent_form_id": { + "name": "consent_form_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "signed_at": { + "name": "signed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "signature_data": { + "name": "signature_data", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip_address": { + "name": "ip_address", + "type": "inet", + "primaryKey": false, + "notNull": false + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_participant_consent_participant_id_hs_participant_id_fk": { + "name": "hs_participant_consent_participant_id_hs_participant_id_fk", + "tableFrom": "hs_participant_consent", + "tableTo": "hs_participant", + "columnsFrom": [ + "participant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_participant_consent_consent_form_id_hs_consent_form_id_fk": { + "name": "hs_participant_consent_consent_form_id_hs_consent_form_id_fk", + "tableFrom": "hs_participant_consent", + "tableTo": "hs_consent_form", + "columnsFrom": [ + "consent_form_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_participant_consent_participant_id_consent_form_id_unique": { + "name": "hs_participant_consent_participant_id_consent_form_id_unique", + "nullsNotDistinct": false, + "columns": [ + "participant_id", + "consent_form_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_participant_document": { + "name": "hs_participant_document", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "participant_id": { + "name": "participant_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "storage_path": { + "name": "storage_path", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_size": { + "name": "file_size", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "participant_document_participant_idx": { + "name": "participant_document_participant_idx", + "columns": [ + { + "expression": "participant_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_participant_document_participant_id_hs_participant_id_fk": { + "name": "hs_participant_document_participant_id_hs_participant_id_fk", + "tableFrom": "hs_participant_document", + "tableTo": "hs_participant", + "columnsFrom": [ + "participant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_participant_document_uploaded_by_hs_user_id_fk": { + "name": "hs_participant_document_uploaded_by_hs_user_id_fk", + "tableFrom": "hs_participant_document", + "tableTo": "hs_user", + "columnsFrom": [ + "uploaded_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_participant": { + "name": "hs_participant", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "participant_code": { + "name": "participant_code", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "demographics": { + "name": "demographics", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "consent_date": { + "name": "consent_date", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_participant_study_id_hs_study_id_fk": { + "name": "hs_participant_study_id_hs_study_id_fk", + "tableFrom": "hs_participant", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_participant_study_id_participant_code_unique": { + "name": "hs_participant_study_id_participant_code_unique", + "nullsNotDistinct": false, + "columns": [ + "study_id", + "participant_code" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_permission": { + "name": "hs_permission", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resource": { + "name": "resource", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "action": { + "name": "action", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_permission_name_unique": { + "name": "hs_permission_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_plugin_repository": { + "name": "hs_plugin_repository", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trust_level": { + "name": "trust_level", + "type": "trust_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'community'" + }, + "is_enabled": { + "name": "is_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "is_official": { + "name": "is_official", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "last_sync_at": { + "name": "last_sync_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "sync_status": { + "name": "sync_status", + "type": "varchar(50)", + "primaryKey": false, + "notNull": false, + "default": "'pending'" + }, + "sync_error": { + "name": "sync_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "hs_plugin_repository_created_by_hs_user_id_fk": { + "name": "hs_plugin_repository_created_by_hs_user_id_fk", + "tableFrom": "hs_plugin_repository", + "tableTo": "hs_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_plugin_repository_url_unique": { + "name": "hs_plugin_repository_url_unique", + "nullsNotDistinct": false, + "columns": [ + "url" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_plugin": { + "name": "hs_plugin", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "robot_id": { + "name": "robot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "identifier": { + "name": "identifier", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "author": { + "name": "author", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "repository_url": { + "name": "repository_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trust_level": { + "name": "trust_level", + "type": "trust_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "plugin_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "configuration_schema": { + "name": "configuration_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "action_definitions": { + "name": "action_definitions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_plugin_robot_id_hs_robot_id_fk": { + "name": "hs_plugin_robot_id_hs_robot_id_fk", + "tableFrom": "hs_plugin", + "tableTo": "hs_robot", + "columnsFrom": [ + "robot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_plugin_identifier_unique": { + "name": "hs_plugin_identifier_unique", + "nullsNotDistinct": false, + "columns": [ + "identifier" + ] + }, + "hs_plugin_name_version_unique": { + "name": "hs_plugin_name_version_unique", + "nullsNotDistinct": false, + "columns": [ + "name", + "version" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_robot_plugin": { + "name": "hs_robot_plugin", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "version": { + "name": "version", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "manufacturer": { + "name": "manufacturer", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "robot_id": { + "name": "robot_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "communication_protocol": { + "name": "communication_protocol", + "type": "communication_protocol", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "plugin_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "config_schema": { + "name": "config_schema", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "capabilities": { + "name": "capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "trust_level": { + "name": "trust_level", + "type": "trust_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'community'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_robot_plugin_robot_id_hs_robot_id_fk": { + "name": "hs_robot_plugin_robot_id_hs_robot_id_fk", + "tableFrom": "hs_robot_plugin", + "tableTo": "hs_robot", + "columnsFrom": [ + "robot_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_robot": { + "name": "hs_robot", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "manufacturer": { + "name": "manufacturer", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capabilities": { + "name": "capabilities", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "communication_protocol": { + "name": "communication_protocol", + "type": "communication_protocol", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_role_permission": { + "name": "hs_role_permission", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "role": { + "name": "role", + "type": "system_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "permission_id": { + "name": "permission_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "hs_role_permission_permission_id_hs_permission_id_fk": { + "name": "hs_role_permission_permission_id_hs_permission_id_fk", + "tableFrom": "hs_role_permission", + "tableTo": "hs_permission", + "columnsFrom": [ + "permission_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_role_permission_role_permission_id_unique": { + "name": "hs_role_permission_role_permission_id_unique", + "nullsNotDistinct": false, + "columns": [ + "role", + "permission_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_sensor_data": { + "name": "hs_sensor_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trial_id": { + "name": "trial_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "sensor_type": { + "name": "sensor_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "robot_state": { + "name": "robot_state", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "sensor_data_trial_timestamp_idx": { + "name": "sensor_data_trial_timestamp_idx", + "columns": [ + { + "expression": "trial_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_sensor_data_trial_id_hs_trial_id_fk": { + "name": "hs_sensor_data_trial_id_hs_trial_id_fk", + "tableFrom": "hs_sensor_data", + "tableTo": "hs_trial", + "columnsFrom": [ + "trial_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_session": { + "name": "hs_session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "session_token": { + "name": "session_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": { + "session_user_id_idx": { + "name": "session_user_id_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_session_user_id_hs_user_id_fk": { + "name": "hs_session_user_id_hs_user_id_fk", + "tableFrom": "hs_session", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_session_session_token_unique": { + "name": "hs_session_session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "session_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_shared_resource": { + "name": "hs_shared_resource", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "resource_type": { + "name": "resource_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "resource_id": { + "name": "resource_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "shared_by": { + "name": "shared_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "share_token": { + "name": "share_token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "permissions": { + "name": "permissions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[\"read\"]'::jsonb" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "access_count": { + "name": "access_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_shared_resource_study_id_hs_study_id_fk": { + "name": "hs_shared_resource_study_id_hs_study_id_fk", + "tableFrom": "hs_shared_resource", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_shared_resource_shared_by_hs_user_id_fk": { + "name": "hs_shared_resource_shared_by_hs_user_id_fk", + "tableFrom": "hs_shared_resource", + "tableTo": "hs_user", + "columnsFrom": [ + "shared_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_shared_resource_share_token_unique": { + "name": "hs_shared_resource_share_token_unique", + "nullsNotDistinct": false, + "columns": [ + "share_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_step": { + "name": "hs_step", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "experiment_id": { + "name": "experiment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "step_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "order_index": { + "name": "order_index", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "duration_estimate": { + "name": "duration_estimate", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "conditions": { + "name": "conditions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_step_experiment_id_hs_experiment_id_fk": { + "name": "hs_step_experiment_id_hs_experiment_id_fk", + "tableFrom": "hs_step", + "tableTo": "hs_experiment", + "columnsFrom": [ + "experiment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_step_experiment_id_order_index_unique": { + "name": "hs_step_experiment_id_order_index_unique", + "nullsNotDistinct": false, + "columns": [ + "experiment_id", + "order_index" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_study": { + "name": "hs_study", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "institution": { + "name": "institution", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "irb_protocol": { + "name": "irb_protocol", + "type": "varchar(100)", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "study_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "settings": { + "name": "settings", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_study_created_by_hs_user_id_fk": { + "name": "hs_study_created_by_hs_user_id_fk", + "tableFrom": "hs_study", + "tableTo": "hs_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_study_member": { + "name": "hs_study_member", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "study_member_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "joined_at": { + "name": "joined_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "invited_by": { + "name": "invited_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_study_member_study_id_hs_study_id_fk": { + "name": "hs_study_member_study_id_hs_study_id_fk", + "tableFrom": "hs_study_member", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_study_member_user_id_hs_user_id_fk": { + "name": "hs_study_member_user_id_hs_user_id_fk", + "tableFrom": "hs_study_member", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_study_member_invited_by_hs_user_id_fk": { + "name": "hs_study_member_invited_by_hs_user_id_fk", + "tableFrom": "hs_study_member", + "tableTo": "hs_user", + "columnsFrom": [ + "invited_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_study_member_study_id_user_id_unique": { + "name": "hs_study_member_study_id_user_id_unique", + "nullsNotDistinct": false, + "columns": [ + "study_id", + "user_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_study_plugin": { + "name": "hs_study_plugin", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "study_id": { + "name": "study_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "plugin_id": { + "name": "plugin_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "configuration": { + "name": "configuration", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "installed_at": { + "name": "installed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "installed_by": { + "name": "installed_by", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "hs_study_plugin_study_id_hs_study_id_fk": { + "name": "hs_study_plugin_study_id_hs_study_id_fk", + "tableFrom": "hs_study_plugin", + "tableTo": "hs_study", + "columnsFrom": [ + "study_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_study_plugin_plugin_id_hs_plugin_id_fk": { + "name": "hs_study_plugin_plugin_id_hs_plugin_id_fk", + "tableFrom": "hs_study_plugin", + "tableTo": "hs_plugin", + "columnsFrom": [ + "plugin_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hs_study_plugin_installed_by_hs_user_id_fk": { + "name": "hs_study_plugin_installed_by_hs_user_id_fk", + "tableFrom": "hs_study_plugin", + "tableTo": "hs_user", + "columnsFrom": [ + "installed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_study_plugin_study_id_plugin_id_unique": { + "name": "hs_study_plugin_study_id_plugin_id_unique", + "nullsNotDistinct": false, + "columns": [ + "study_id", + "plugin_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_system_setting": { + "name": "hs_system_setting", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "key": { + "name": "key", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_system_setting_updated_by_hs_user_id_fk": { + "name": "hs_system_setting_updated_by_hs_user_id_fk", + "tableFrom": "hs_system_setting", + "tableTo": "hs_user", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_system_setting_key_unique": { + "name": "hs_system_setting_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_trial_event": { + "name": "hs_trial_event", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trial_id": { + "name": "trial_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_type": { + "name": "event_type", + "type": "varchar(50)", + "primaryKey": false, + "notNull": true + }, + "action_id": { + "name": "action_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "data": { + "name": "data", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "trial_events_trial_timestamp_idx": { + "name": "trial_events_trial_timestamp_idx", + "columns": [ + { + "expression": "trial_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "timestamp", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "hs_trial_event_trial_id_hs_trial_id_fk": { + "name": "hs_trial_event_trial_id_hs_trial_id_fk", + "tableFrom": "hs_trial_event", + "tableTo": "hs_trial", + "columnsFrom": [ + "trial_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_trial_event_action_id_hs_action_id_fk": { + "name": "hs_trial_event_action_id_hs_action_id_fk", + "tableFrom": "hs_trial_event", + "tableTo": "hs_action", + "columnsFrom": [ + "action_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hs_trial_event_created_by_hs_user_id_fk": { + "name": "hs_trial_event_created_by_hs_user_id_fk", + "tableFrom": "hs_trial_event", + "tableTo": "hs_user", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_trial": { + "name": "hs_trial", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "experiment_id": { + "name": "experiment_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "participant_id": { + "name": "participant_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "wizard_id": { + "name": "wizard_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "session_number": { + "name": "session_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "status": { + "name": "status", + "type": "trial_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "started_at": { + "name": "started_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "metadata": { + "name": "metadata", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": { + "hs_trial_experiment_id_hs_experiment_id_fk": { + "name": "hs_trial_experiment_id_hs_experiment_id_fk", + "tableFrom": "hs_trial", + "tableTo": "hs_experiment", + "columnsFrom": [ + "experiment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hs_trial_participant_id_hs_participant_id_fk": { + "name": "hs_trial_participant_id_hs_participant_id_fk", + "tableFrom": "hs_trial", + "tableTo": "hs_participant", + "columnsFrom": [ + "participant_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "hs_trial_wizard_id_hs_user_id_fk": { + "name": "hs_trial_wizard_id_hs_user_id_fk", + "tableFrom": "hs_trial", + "tableTo": "hs_user", + "columnsFrom": [ + "wizard_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_user_system_role": { + "name": "hs_user_system_role", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "system_role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "granted_by": { + "name": "granted_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_user_system_role_user_id_hs_user_id_fk": { + "name": "hs_user_system_role_user_id_hs_user_id_fk", + "tableFrom": "hs_user_system_role", + "tableTo": "hs_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_user_system_role_granted_by_hs_user_id_fk": { + "name": "hs_user_system_role_granted_by_hs_user_id_fk", + "tableFrom": "hs_user_system_role", + "tableTo": "hs_user", + "columnsFrom": [ + "granted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_user_system_role_user_id_role_unique": { + "name": "hs_user_system_role_user_id_role_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "role" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_user": { + "name": "hs_user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "email": { + "name": "email", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "name": { + "name": "name", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "varchar(255)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "hs_user_email_unique": { + "name": "hs_user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_verification_token": { + "name": "hs_verification_token", + "schema": "", + "columns": { + "identifier": { + "name": "identifier", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "varchar(255)", + "primaryKey": false, + "notNull": true + }, + "expires": { + "name": "expires", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "hs_verification_token_identifier_token_pk": { + "name": "hs_verification_token_identifier_token_pk", + "columns": [ + "identifier", + "token" + ] + } + }, + "uniqueConstraints": { + "hs_verification_token_token_unique": { + "name": "hs_verification_token_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.hs_wizard_intervention": { + "name": "hs_wizard_intervention", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "trial_id": { + "name": "trial_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "wizard_id": { + "name": "wizard_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "intervention_type": { + "name": "intervention_type", + "type": "varchar(100)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "timestamp": { + "name": "timestamp", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "CURRENT_TIMESTAMP" + }, + "parameters": { + "name": "parameters", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "hs_wizard_intervention_trial_id_hs_trial_id_fk": { + "name": "hs_wizard_intervention_trial_id_hs_trial_id_fk", + "tableFrom": "hs_wizard_intervention", + "tableTo": "hs_trial", + "columnsFrom": [ + "trial_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "hs_wizard_intervention_wizard_id_hs_user_id_fk": { + "name": "hs_wizard_intervention_wizard_id_hs_user_id_fk", + "tableFrom": "hs_wizard_intervention", + "tableTo": "hs_user", + "columnsFrom": [ + "wizard_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.block_category": { + "name": "block_category", + "schema": "public", + "values": [ + "wizard", + "robot", + "control", + "sensor", + "logic", + "event" + ] + }, + "public.block_shape": { + "name": "block_shape", + "schema": "public", + "values": [ + "action", + "control", + "value", + "boolean", + "hat", + "cap" + ] + }, + "public.communication_protocol": { + "name": "communication_protocol", + "schema": "public", + "values": [ + "rest", + "ros2", + "custom" + ] + }, + "public.experiment_status": { + "name": "experiment_status", + "schema": "public", + "values": [ + "draft", + "testing", + "ready", + "deprecated" + ] + }, + "public.export_status": { + "name": "export_status", + "schema": "public", + "values": [ + "pending", + "processing", + "completed", + "failed" + ] + }, + "public.media_type": { + "name": "media_type", + "schema": "public", + "values": [ + "video", + "audio", + "image" + ] + }, + "public.plugin_status": { + "name": "plugin_status", + "schema": "public", + "values": [ + "active", + "deprecated", + "disabled" + ] + }, + "public.step_type": { + "name": "step_type", + "schema": "public", + "values": [ + "wizard", + "robot", + "parallel", + "conditional" + ] + }, + "public.study_member_role": { + "name": "study_member_role", + "schema": "public", + "values": [ + "owner", + "researcher", + "wizard", + "observer" + ] + }, + "public.study_status": { + "name": "study_status", + "schema": "public", + "values": [ + "draft", + "active", + "completed", + "archived" + ] + }, + "public.system_role": { + "name": "system_role", + "schema": "public", + "values": [ + "administrator", + "researcher", + "wizard", + "observer" + ] + }, + "public.trial_status": { + "name": "trial_status", + "schema": "public", + "values": [ + "scheduled", + "in_progress", + "completed", + "aborted", + "failed" + ] + }, + "public.trust_level": { + "name": "trust_level", + "schema": "public", + "values": [ + "official", + "verified", + "community" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..57e437b --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1774137504617, + "tag": "0000_old_tattoo", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/scripts/migrate-add-identifier.ts b/scripts/migrate-add-identifier.ts new file mode 100644 index 0000000..1d6b34d --- /dev/null +++ b/scripts/migrate-add-identifier.ts @@ -0,0 +1,31 @@ +import { db } from "~/server/db"; +import { sql } from "drizzle-orm"; + +async function migrate() { + console.log("Adding identifier column to hs_plugin..."); + + try { + await db.execute(sql`ALTER TABLE hs_plugin ADD COLUMN identifier varchar(100)`); + console.log("✓ Added identifier column"); + } catch (e: any) { + console.log("Column may already exist:", e.message); + } + + try { + await db.execute(sql`UPDATE hs_plugin SET identifier = name WHERE identifier IS NULL`); + console.log("✓ Copied name to identifier"); + } catch (e: any) { + console.log("Error copying:", e.message); + } + + try { + await db.execute(sql`ALTER TABLE hs_plugin ADD CONSTRAINT hs_plugin_identifier_unique UNIQUE (identifier)`); + console.log("✓ Added unique constraint"); + } catch (e: any) { + console.log("Constraint may already exist:", e.message); + } + + console.log("Migration complete!"); +} + +migrate().catch(console.error); diff --git a/scripts/seed-dev.ts b/scripts/seed-dev.ts index abd9f5e..a8e9809 100755 --- a/scripts/seed-dev.ts +++ b/scripts/seed-dev.ts @@ -159,6 +159,7 @@ async function main() { .insert(schema.plugins) .values({ robotId: naoRobot!.id, + identifier: NAO_PLUGIN_DEF.robotId, name: NAO_PLUGIN_DEF.name, version: NAO_PLUGIN_DEF.version, description: NAO_PLUGIN_DEF.description, diff --git a/src/server/db/schema.ts b/src/server/db/schema.ts index 8cee88c..4545c0f 100755 --- a/src/server/db/schema.ts +++ b/src/server/db/schema.ts @@ -608,6 +608,7 @@ export const plugins = createTable( robotId: uuid("robot_id").references(() => robots.id, { onDelete: "cascade", }), + identifier: varchar("identifier", { length: 100 }).notNull().unique(), name: varchar("name", { length: 255 }).notNull(), version: varchar("version", { length: 50 }).notNull(), description: text("description"), diff --git a/src/server/services/trial-execution.ts b/src/server/services/trial-execution.ts index feee992..410fda8 100755 --- a/src/server/services/trial-execution.ts +++ b/src/server/services/trial-execution.ts @@ -653,20 +653,37 @@ export class TrialExecutionEngine { pluginName, ); - const query = isUuid - ? eq(plugins.id, pluginName) - : eq(plugins.name, pluginName); - - const [plugin] = await this.db - .select() - .from(plugins) - .where(query) - .limit(1); + let plugin; + if (isUuid) { + const [result] = await this.db + .select() + .from(plugins) + .where(eq(plugins.id, pluginName)) + .limit(1); + plugin = result; + } else { + // Look up by identifier first (e.g., "nao6-ros2"), then fall back to name + const [byIdentifier] = await this.db + .select() + .from(plugins) + .where(eq(plugins.identifier, pluginName)) + .limit(1); + + if (byIdentifier) { + plugin = byIdentifier; + } else { + const [byName] = await this.db + .select() + .from(plugins) + .where(eq(plugins.name, pluginName)) + .limit(1); + plugin = byName; + } + } if (plugin) { // Cache the plugin definition - // Use the actual name for cache key if we looked up by ID - const cacheKey = isUuid ? plugin.name : pluginName; + const cacheKey = isUuid ? plugin.id : plugin.identifier; const pluginData = { ...plugin, @@ -676,10 +693,13 @@ export class TrialExecutionEngine { }; this.pluginCache.set(cacheKey, pluginData); - // Also cache by ID if accessible + // Also cache by ID and identifier if (plugin.id) { this.pluginCache.set(plugin.id, pluginData); } + if (plugin.identifier) { + this.pluginCache.set(plugin.identifier, pluginData); + } return pluginData; }