Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🗃️ feat(database): add channel data model (#21407)

AmAzing-39e08aa66e69
diff --git a/apps/server/src/services/agent/index.ts b/apps/server/src/services/agent/index.ts
index 80e554dfcf3..7185fe02879 100644
--- a/apps/server/src/services/agent/index.ts
+++ b/apps/server/src/services/agent/index.ts
@@ -1,7 +1,7 @@
import { type BuiltinAgentSlug } from '@lobechat/builtin-agents';
import { BUILTIN_AGENTS } from '@lobechat/builtin-agents';
import { DEFAULT_PROVIDER } from '@lobechat/business-const';
-import { DEFAULT_AGENT_CONFIG, DEFAULT_MODEL } from '@lobechat/const';
+import { DEFAULT_MODEL } from '@lobechat/const';
import { type LobeChatDatabase } from '@lobechat/database';
import {
type AgentItem,
@@ -9,7 +9,6 @@ import {
type LobeAgentChatConfig,
type LobeAgentConfig,
} from '@lobechat/types';
-import { cleanObject, merge } from '@lobechat/utils';
import { TRPCError } from '@trpc/server';
import debug from 'debug';
import { type PartialDeep } from 'type-fest';
@@ -21,6 +20,7 @@ import { ResourcePermissionModel } from '@/database/models/resourcePermission';
import { SessionModel } from '@/database/models/session';
import { UserModel } from '@/database/models/user';
import { DEFAULT_RESOURCE_ACCESS_LEVELS } from '@/database/schemas';
+import { mergeAgentDefaultConfig } from '@/database/utils/agentConfig';
import { normalizeInboxAgentAvatar, normalizeInboxAgentTitle } from '@/database/utils/inboxAgent';
import { getRedisConfig } from '@/envs/redis';
import { getServerDefaultAgentConfig } from '@/server/globalConfig';
@@ -352,20 +352,11 @@ export class AgentService {
): LobeAgentConfig | null {
if (!agent) return null;
- // Merge configs in order: DEFAULT -> server -> [user] -> agent
- const serverDefaultAgentConfig = getServerDefaultAgentConfig();
- const baseConfig = merge(DEFAULT_AGENT_CONFIG, serverDefaultAgentConfig);
-
- // Skip the personal default layer for workspace-scoped agents (see above).
- if (this.workspaceId) {
- return merge(baseConfig, cleanObject(agent));
- }
-
- const userDefaultAgentConfig =
- (defaultAgentConfig as { config?: PartialDeep<LobeAgentConfig> })?.config || {};
- const withUserConfig = merge(baseConfig, userDefaultAgentConfig);
-
- return merge(withUserConfig, cleanObject(agent));
+ return mergeAgentDefaultConfig(agent, {
+ serverDefault: getServerDefaultAgentConfig(),
+ userDefault: defaultAgentConfig,
+ workspaceId: this.workspaceId,
+ });
}
/**
diff --git a/docs/development/database-schema.dbml b/docs/development/database-schema.dbml
index 8dfc1fb2392..2d5169f1037 100644
--- a/docs/development/database-schema.dbml
+++ b/docs/development/database-schema.dbml
@@ -1196,6 +1196,205 @@ table verifications {
}
}
+table channel_audit {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ channel_id text [not null]
+ event text [not null]
+ target_id text [not null]
+ details jsonb [not null, default: `{}`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (channel_id, event, created_at) [name: 'channel_audit_channel_event_idx']
+ (target_id, event, created_at) [name: 'channel_audit_target_event_idx']
+ }
+}
+
+table channel_jobs {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ channel_id text [not null]
+ member_id uuid [not null]
+ message_id uuid [not null]
+ thread_id text
+ requester_member_id uuid [not null]
+ delivery_key text [not null, default: 'initial']
+ status text [not null, default: 'queued']
+ blocked_reason text
+ blocked_code text
+ claimed_at "timestamp with time zone"
+ topic_id text
+ operation_id text [unique]
+ manifest jsonb
+ execution_config jsonb
+ device_id varchar(64)
+ working_directory text
+ accepted_at "timestamp with time zone"
+ lease_owner text
+ lease_expires_at "timestamp with time zone"
+ writer_held boolean [not null, default: false]
+ isolated_at "timestamp with time zone"
+ draft text
+ publication_revoked boolean [not null, default: false]
+ published_message_id uuid
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (channel_id, id) [name: 'channel_jobs_scope_unique', unique]
+ (message_id, member_id, delivery_key) [name: 'channel_jobs_delivery_unique', unique]
+ (channel_id, status) [name: 'channel_jobs_channel_status_idx']
+ (member_id, requester_member_id, thread_id, claimed_at) [name: 'channel_jobs_continuation_idx']
+ (topic_id, published_message_id) [name: 'channel_jobs_topic_idx']
+ (member_id, status, created_at) [name: 'channel_jobs_member_queue_idx']
+ lease_expires_at [name: 'channel_jobs_lease_expires_idx']
+ member_id [name: 'channel_jobs_active_member_unique', unique]
+ (device_id, working_directory) [name: 'channel_jobs_active_directory_unique', unique]
+
+
+
+
+ }
+}
+
+table channel_member_grants {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ channel_id text [not null]
+ member_id uuid [not null]
+ device_owner_id text [not null]
+ device_id varchar(64) [not null]
+ working_directory text [not null]
+ requested_by_member_id uuid [not null]
+ status text [not null, default: 'pending']
+ decided_at "timestamp with time zone"
+ revoked_at "timestamp with time zone"
+ revoke_reason text
+ metadata jsonb [default: `{}`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ member_id [name: 'channel_member_grants_member_unique', unique]
+ (device_owner_id, status) [name: 'channel_member_grants_owner_status_idx']
+
+
+ }
+}
+
+table channel_members {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ channel_id text [not null]
+ actor_type text [not null]
+ user_id text
+ role text
+ last_read_sequence integer
+ agent_id text
+ name text
+ description text [not null, default: '']
+ config jsonb
+ metadata jsonb [default: `{}`]
+ active boolean [not null, default: true]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (channel_id, id) [name: 'channel_members_scope_unique', unique]
+ (channel_id, user_id) [name: 'channel_members_channel_user_unique', unique]
+ user_id [name: 'channel_members_user_id_idx']
+ agent_id [name: 'channel_members_agent_id_idx']
+
+
+
+
+
+
+
+ }
+}
+
+table channel_message_files {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ message_id uuid [not null]
+ file_id text [not null]
+ sort_order integer [not null]
+
+ indexes {
+ (message_id, file_id) [name: 'channel_message_files_message_file_unique', unique]
+ file_id [name: 'channel_message_files_file_idx']
+ }
+}
+
+table channel_messages {
+ id uuid [pk, not null, default: `gen_random_uuid()`]
+ channel_id text [not null]
+ thread_id text
+ sequence integer [not null]
+ content text [not null]
+ user_id text
+ agent_id text
+ mentions jsonb [not null, default: `[]`]
+ request_key text [not null]
+ reply_to_id uuid
+ routing_status text [not null]
+ routing_source text
+ routing_reason text
+ routing_attempt integer [not null, default: 0]
+ recipient_member_ids jsonb [not null, default: `[]`]
+ metadata jsonb [default: `{}`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (channel_id, id) [name: 'channel_messages_scope_unique', unique]
+ (channel_id, sequence) [name: 'channel_messages_sequence_unique', unique]
+ (channel_id, request_key) [name: 'channel_messages_request_key_unique', unique]
+ (channel_id, thread_id, sequence) [name: 'channel_messages_thread_sequence_idx']
+ (channel_id, thread_id, sequence) [name: 'channel_messages_request_sequence_idx']
+ (channel_id, id) [name: 'channel_messages_routing_pending_idx']
+
+
+
+
+ }
+}
+
+table channel_threads {
+ id text [pk, not null]
+ channel_id text [not null]
+ root_message_id uuid [not null]
+ root_sequence integer [not null]
+ follower_member_ids jsonb [not null, default: `[]`]
+ metadata jsonb [default: `{}`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ (channel_id, id) [name: 'channel_threads_scope_unique', unique]
+ (channel_id, root_message_id) [name: 'channel_threads_root_unique', unique]
+
+ }
+}
+
+table channels {
+ id text [pk, not null]
+ user_id text
+ workspace_id text
+ project_id text
+ agent_id text
+ title text [not null]
+ sequence integer [not null, default: 0]
+ archived boolean [not null, default: false]
+ visibility text [not null, default: 'private']
+ metadata jsonb [default: `{}`]
+ created_at "timestamp with time zone" [not null, default: `now()`]
+ updated_at "timestamp with time zone" [not null, default: `now()`]
+
+ indexes {
+ user_id [name: 'channels_user_id_idx']
+ (agent_id, user_id, workspace_id) [name: 'channels_direct_unique', unique]
+
+ project_id [name: 'channels_project_id_idx']
+ (workspace_id, visibility) [name: 'channels_workspace_visibility_idx']
+ }
+}
+
table chat_groups {
id text [pk, not null]
title text
@@ -5053,4 +5252,4 @@ ref: topic_documents.document_id > documents.id
ref: topic_documents.topic_id > topics.id
-ref: topics.session_id - sessions.id
\ No newline at end of file
+ref: topics.session_id - sessions.id
diff --git a/packages/database/migrations/0184_channel_tables.sql b/packages/database/migrations/0184_channel_tables.sql
new file mode 100644
index 00000000000..d6cd9778ad1
--- /dev/null
+++ b/packages/database/migrations/0184_channel_tables.sql
@@ -0,0 +1,222 @@
+CREATE TABLE IF NOT EXISTS "channel_audit" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "channel_id" text NOT NULL,
+ "event" text NOT NULL,
+ "target_id" text NOT NULL,
+ "details" jsonb DEFAULT '{}'::jsonb NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_jobs" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "channel_id" text NOT NULL,
+ "member_id" uuid NOT NULL,
+ "message_id" uuid NOT NULL,
+ "thread_id" text,
+ "requester_member_id" uuid NOT NULL,
+ "delivery_key" text DEFAULT 'initial' NOT NULL,
+ "status" text DEFAULT 'queued' NOT NULL,
+ "blocked_reason" text,
+ "blocked_code" text,
+ "claimed_at" timestamp with time zone,
+ "topic_id" text,
+ "operation_id" text,
+ "manifest" jsonb,
+ "execution_config" jsonb,
+ "device_id" varchar(64),
+ "working_directory" text,
+ "accepted_at" timestamp with time zone,
+ "lease_owner" text,
+ "lease_expires_at" timestamp with time zone,
+ "writer_held" boolean DEFAULT false NOT NULL,
+ "isolated_at" timestamp with time zone,
+ "draft" text,
+ "publication_revoked" boolean DEFAULT false NOT NULL,
+ "published_message_id" uuid,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "channel_jobs_operation_id_unique" UNIQUE("operation_id"),
+ CONSTRAINT "channel_jobs_scope_unique" UNIQUE("channel_id","id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_member_grants" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "channel_id" text NOT NULL,
+ "member_id" uuid NOT NULL,
+ "device_owner_id" text NOT NULL,
+ "device_id" varchar(64) NOT NULL,
+ "working_directory" text NOT NULL,
+ "requested_by_member_id" uuid NOT NULL,
+ "status" text DEFAULT 'pending' NOT NULL,
+ "decided_at" timestamp with time zone,
+ "revoked_at" timestamp with time zone,
+ "revoke_reason" text,
+ "metadata" jsonb DEFAULT '{}'::jsonb,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_members" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "channel_id" text NOT NULL,
+ "actor_type" text NOT NULL,
+ "user_id" text,
+ "role" text,
+ "last_read_sequence" integer,
+ "agent_id" text,
+ "name" text,
+ "description" text DEFAULT '' NOT NULL,
+ "config" jsonb,
+ "metadata" jsonb DEFAULT '{}'::jsonb,
+ "active" boolean DEFAULT true NOT NULL,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "channel_members_scope_unique" UNIQUE("channel_id","id"),
+ CONSTRAINT "channel_members_actor_type_check" CHECK ("channel_members"."actor_type" IN ('user', 'agent')),
+ CONSTRAINT "channel_members_user_shape_check" CHECK ("channel_members"."actor_type" <> 'user' OR "channel_members"."role" IS NOT NULL),
+ CONSTRAINT "channel_members_agent_shape_check" CHECK ("channel_members"."actor_type" <> 'agent' OR ("channel_members"."name" IS NOT NULL AND "channel_members"."config" IS NOT NULL)),
+ CONSTRAINT "channel_members_user_id_owner_check" CHECK ("channel_members"."user_id" IS NULL OR "channel_members"."actor_type" = 'user'),
+ CONSTRAINT "channel_members_role_owner_check" CHECK ("channel_members"."role" IS NULL OR "channel_members"."actor_type" = 'user'),
+ CONSTRAINT "channel_members_agent_id_owner_check" CHECK ("channel_members"."agent_id" IS NULL OR "channel_members"."actor_type" = 'agent'),
+ CONSTRAINT "channel_members_config_owner_check" CHECK ("channel_members"."config" IS NULL OR "channel_members"."actor_type" <> 'user')
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_message_files" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "message_id" uuid NOT NULL,
+ "file_id" text NOT NULL,
+ "sort_order" integer NOT NULL,
+ CONSTRAINT "channel_message_files_message_file_unique" UNIQUE("message_id","file_id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_messages" (
+ "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
+ "channel_id" text NOT NULL,
+ "thread_id" text,
+ "sequence" integer NOT NULL,
+ "content" text NOT NULL,
+ "user_id" text,
+ "agent_id" text,
+ "mentions" jsonb DEFAULT '[]'::jsonb NOT NULL,
+ "request_key" text NOT NULL,
+ "reply_to_id" uuid,
+ "routing_status" text NOT NULL,
+ "routing_source" text,
+ "routing_reason" text,
+ "routing_attempt" integer DEFAULT 0 NOT NULL,
+ "recipient_member_ids" jsonb DEFAULT '[]'::jsonb NOT NULL,
+ "metadata" jsonb DEFAULT '{}'::jsonb,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "channel_messages_scope_unique" UNIQUE("channel_id","id"),
+ CONSTRAINT "channel_messages_sender_check" CHECK ("channel_messages"."user_id" IS NULL OR "channel_messages"."agent_id" IS NULL),
+ CONSTRAINT "channel_messages_user_sender_check" CHECK ("channel_messages"."routing_status" <> 'reply' OR "channel_messages"."user_id" IS NULL),
+ CONSTRAINT "channel_messages_agent_sender_check" CHECK ("channel_messages"."routing_status" = 'reply' OR "channel_messages"."agent_id" IS NULL)
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channel_threads" (
+ "id" text PRIMARY KEY NOT NULL,
+ "channel_id" text NOT NULL,
+ "root_message_id" uuid NOT NULL,
+ "root_sequence" integer NOT NULL,
+ "follower_member_ids" jsonb DEFAULT '[]'::jsonb NOT NULL,
+ "metadata" jsonb DEFAULT '{}'::jsonb,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "channel_threads_scope_unique" UNIQUE("channel_id","id")
+);
+--> statement-breakpoint
+CREATE TABLE IF NOT EXISTS "channels" (
+ "id" text PRIMARY KEY NOT NULL,
+ "user_id" text,
+ "workspace_id" text,
+ "project_id" text,
+ "agent_id" text,
+ "title" text NOT NULL,
+ "sequence" integer DEFAULT 0 NOT NULL,
+ "archived" boolean DEFAULT false NOT NULL,
+ "visibility" text DEFAULT 'private' NOT NULL,
+ "metadata" jsonb DEFAULT '{}'::jsonb,
+ "created_at" timestamp with time zone DEFAULT now() NOT NULL,
+ "updated_at" timestamp with time zone DEFAULT now() NOT NULL,
+ CONSTRAINT "channels_direct_visibility_check" CHECK ("channels"."agent_id" IS NULL OR "channels"."visibility" = 'private')
+);
+--> statement-breakpoint
+ALTER TABLE "channel_audit" DROP CONSTRAINT IF EXISTS "channel_audit_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_audit" ADD CONSTRAINT "channel_audit_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_topic_id_topics_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_topic_id_topics_id_fk" FOREIGN KEY ("topic_id") REFERENCES "public"."topics"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_operation_id_agent_operations_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_operation_id_agent_operations_id_fk" FOREIGN KEY ("operation_id") REFERENCES "public"."agent_operations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_member_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_member_fk" FOREIGN KEY ("channel_id","member_id") REFERENCES "public"."channel_members"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_requester_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_requester_fk" FOREIGN KEY ("channel_id","requester_member_id") REFERENCES "public"."channel_members"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_message_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_message_fk" FOREIGN KEY ("channel_id","message_id") REFERENCES "public"."channel_messages"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_jobs" DROP CONSTRAINT IF EXISTS "channel_jobs_thread_fk";--> statement-breakpoint
+ALTER TABLE "channel_jobs" ADD CONSTRAINT "channel_jobs_thread_fk" FOREIGN KEY ("channel_id","thread_id") REFERENCES "public"."channel_threads"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_member_grants" DROP CONSTRAINT IF EXISTS "channel_member_grants_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_member_grants" ADD CONSTRAINT "channel_member_grants_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_member_grants" DROP CONSTRAINT IF EXISTS "channel_member_grants_device_owner_id_users_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_member_grants" ADD CONSTRAINT "channel_member_grants_device_owner_id_users_id_fk" FOREIGN KEY ("device_owner_id") REFERENCES "public"."users"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_member_grants" DROP CONSTRAINT IF EXISTS "channel_member_grants_member_fk";--> statement-breakpoint
+ALTER TABLE "channel_member_grants" ADD CONSTRAINT "channel_member_grants_member_fk" FOREIGN KEY ("channel_id","member_id") REFERENCES "public"."channel_members"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_member_grants" DROP CONSTRAINT IF EXISTS "channel_member_grants_requester_fk";--> statement-breakpoint
+ALTER TABLE "channel_member_grants" ADD CONSTRAINT "channel_member_grants_requester_fk" FOREIGN KEY ("channel_id","requested_by_member_id") REFERENCES "public"."channel_members"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_members" DROP CONSTRAINT IF EXISTS "channel_members_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_members" ADD CONSTRAINT "channel_members_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_members" DROP CONSTRAINT IF EXISTS "channel_members_user_id_users_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_members" ADD CONSTRAINT "channel_members_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_members" DROP CONSTRAINT IF EXISTS "channel_members_agent_id_agents_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_members" ADD CONSTRAINT "channel_members_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_message_files" DROP CONSTRAINT IF EXISTS "channel_message_files_message_id_channel_messages_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_message_files" ADD CONSTRAINT "channel_message_files_message_id_channel_messages_id_fk" FOREIGN KEY ("message_id") REFERENCES "public"."channel_messages"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_message_files" DROP CONSTRAINT IF EXISTS "channel_message_files_file_id_files_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_message_files" ADD CONSTRAINT "channel_message_files_file_id_files_id_fk" FOREIGN KEY ("file_id") REFERENCES "public"."files"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_messages" DROP CONSTRAINT IF EXISTS "channel_messages_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_messages" ADD CONSTRAINT "channel_messages_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_messages" DROP CONSTRAINT IF EXISTS "channel_messages_user_id_users_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_messages" ADD CONSTRAINT "channel_messages_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_messages" DROP CONSTRAINT IF EXISTS "channel_messages_agent_id_agents_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_messages" ADD CONSTRAINT "channel_messages_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_messages" DROP CONSTRAINT IF EXISTS "channel_messages_thread_fk";--> statement-breakpoint
+ALTER TABLE "channel_messages" ADD CONSTRAINT "channel_messages_thread_fk" FOREIGN KEY ("channel_id","thread_id") REFERENCES "public"."channel_threads"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_threads" DROP CONSTRAINT IF EXISTS "channel_threads_channel_id_channels_id_fk";--> statement-breakpoint
+ALTER TABLE "channel_threads" ADD CONSTRAINT "channel_threads_channel_id_channels_id_fk" FOREIGN KEY ("channel_id") REFERENCES "public"."channels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channel_threads" DROP CONSTRAINT IF EXISTS "channel_threads_root_fk";--> statement-breakpoint
+ALTER TABLE "channel_threads" ADD CONSTRAINT "channel_threads_root_fk" FOREIGN KEY ("channel_id","root_message_id") REFERENCES "public"."channel_messages"("channel_id","id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channels" DROP CONSTRAINT IF EXISTS "channels_user_id_users_id_fk";--> statement-breakpoint
+ALTER TABLE "channels" ADD CONSTRAINT "channels_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channels" DROP CONSTRAINT IF EXISTS "channels_workspace_id_workspaces_id_fk";--> statement-breakpoint
+ALTER TABLE "channels" ADD CONSTRAINT "channels_workspace_id_workspaces_id_fk" FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channels" DROP CONSTRAINT IF EXISTS "channels_project_id_projects_id_fk";--> statement-breakpoint
+ALTER TABLE "channels" ADD CONSTRAINT "channels_project_id_projects_id_fk" FOREIGN KEY ("project_id") REFERENCES "public"."projects"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
+ALTER TABLE "channels" DROP CONSTRAINT IF EXISTS "channels_agent_id_agents_id_fk";--> statement-breakpoint
+ALTER TABLE "channels" ADD CONSTRAINT "channels_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_audit_channel_event_idx" ON "channel_audit" USING btree ("channel_id","event","created_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_audit_target_event_idx" ON "channel_audit" USING btree ("target_id","event","created_at");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_jobs_delivery_unique" ON "channel_jobs" USING btree ("message_id","member_id","delivery_key");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_jobs_channel_status_idx" ON "channel_jobs" USING btree ("channel_id","status");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_jobs_continuation_idx" ON "channel_jobs" USING btree ("member_id","requester_member_id","thread_id","claimed_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_jobs_topic_idx" ON "channel_jobs" USING btree ("topic_id","published_message_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_jobs_member_queue_idx" ON "channel_jobs" USING btree ("member_id","status","created_at");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_jobs_lease_expires_idx" ON "channel_jobs" USING btree ("lease_expires_at") WHERE "channel_jobs"."writer_held" AND "channel_jobs"."isolated_at" IS NULL;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_jobs_active_member_unique" ON "channel_jobs" USING btree ("member_id") WHERE "channel_jobs"."writer_held" AND "channel_jobs"."isolated_at" IS NULL;--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_jobs_active_directory_unique" ON "channel_jobs" USING btree ("device_id","working_directory") WHERE "channel_jobs"."device_id" IS NOT NULL AND "channel_jobs"."working_directory" IS NOT NULL AND "channel_jobs"."writer_held";--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_member_grants_member_unique" ON "channel_member_grants" USING btree ("member_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_member_grants_owner_status_idx" ON "channel_member_grants" USING btree ("device_owner_id","status");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_members_channel_user_unique" ON "channel_members" USING btree ("channel_id","user_id") WHERE "channel_members"."user_id" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_members_user_id_idx" ON "channel_members" USING btree ("user_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_members_agent_id_idx" ON "channel_members" USING btree ("agent_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_message_files_file_idx" ON "channel_message_files" USING btree ("file_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_messages_sequence_unique" ON "channel_messages" USING btree ("channel_id","sequence");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_messages_request_key_unique" ON "channel_messages" USING btree ("channel_id","request_key");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_messages_thread_sequence_idx" ON "channel_messages" USING btree ("channel_id","thread_id","sequence");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_messages_request_sequence_idx" ON "channel_messages" USING btree ("channel_id","thread_id","sequence") WHERE "channel_messages"."routing_status" <> 'reply';--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channel_messages_routing_pending_idx" ON "channel_messages" USING btree ("channel_id","id") WHERE "channel_messages"."routing_status" = 'pending';--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channel_threads_root_unique" ON "channel_threads" USING btree ("channel_id","root_message_id");--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channels_user_id_idx" ON "channels" USING btree ("user_id");--> statement-breakpoint
+CREATE UNIQUE INDEX IF NOT EXISTS "channels_direct_unique" ON "channels" USING btree ("agent_id","user_id",coalesce("workspace_id", '')) WHERE "channels"."agent_id" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channels_project_id_idx" ON "channels" USING btree ("project_id") WHERE "channels"."project_id" IS NOT NULL;--> statement-breakpoint
+CREATE INDEX IF NOT EXISTS "channels_workspace_visibility_idx" ON "channels" USING btree ("workspace_id","visibility");
diff --git a/packages/database/migrations/meta/0184_snapshot.json b/packages/database/migrations/meta/0184_snapshot.json
new file mode 100644
index 00000000000..01c6eac98fb
--- /dev/null
+++ b/packages/database/migrations/meta/0184_snapshot.json
@@ -0,0 +1,43446 @@
+{
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ },
+ "dialect": "postgresql",
+ "enums": {},
+ "id": "5eb76168-4960-4d66-8711-f6865ca19f4b",
+ "policies": {},
+ "prevId": "441054df-5d72-4ff2-b7fc-742c8cfb5db5",
+ "roles": {},
+ "schemas": {},
+ "sequences": {
+ "public.fts_search_sync_revision_seq": {
+ "name": "fts_search_sync_revision_seq",
+ "schema": "public",
+ "increment": "1",
+ "startWith": "1",
+ "minValue": "1",
+ "maxValue": "9223372036854775807",
+ "cache": "1",
+ "cycle": false
+ }
+ },
+ "tables": {
+ "public.acceptance_comments": {
+ "name": "acceptance_comments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "acceptance_id": {
+ "name": "acceptance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_agent_id": {
+ "name": "author_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_comment_id": {
+ "name": "parent_comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'comment'"
+ },
+ "anchor_type": {
+ "name": "anchor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'acceptance'"
+ },
+ "context_run_id": {
+ "name": "context_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_item_id": {
+ "name": "check_item_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_id": {
+ "name": "evidence_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "anchor_rect": {
+ "name": "anchor_rect",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_by_user_id": {
+ "name": "resolved_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "acceptance_comments_acceptance_id_author_user_id_client_id_unique": {
+ "name": "acceptance_comments_acceptance_id_author_user_id_client_id_unique",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_acceptance_id_created_at_id_idx": {
+ "name": "acceptance_comments_acceptance_id_created_at_id_idx",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_parent_comment_id_idx": {
+ "name": "acceptance_comments_parent_comment_id_idx",
+ "columns": [
+ {
+ "expression": "parent_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_evidence_id_idx": {
+ "name": "acceptance_comments_evidence_id_idx",
+ "columns": [
+ {
+ "expression": "evidence_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_author_user_id_idx": {
+ "name": "acceptance_comments_author_user_id_idx",
+ "columns": [
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_author_agent_id_idx": {
+ "name": "acceptance_comments_author_agent_id_idx",
+ "columns": [
+ {
+ "expression": "author_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_comments_workspace_id_idx": {
+ "name": "acceptance_comments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_comments_acceptance_id_acceptances_id_fk": {
+ "name": "acceptance_comments_acceptance_id_acceptances_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "acceptances",
+ "columnsFrom": ["acceptance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_author_user_id_users_id_fk": {
+ "name": "acceptance_comments_author_user_id_users_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "users",
+ "columnsFrom": ["author_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_author_agent_id_agents_id_fk": {
+ "name": "acceptance_comments_author_agent_id_agents_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "agents",
+ "columnsFrom": ["author_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_workspace_id_workspaces_id_fk": {
+ "name": "acceptance_comments_workspace_id_workspaces_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_parent_comment_id_acceptance_comments_id_fk": {
+ "name": "acceptance_comments_parent_comment_id_acceptance_comments_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "acceptance_comments",
+ "columnsFrom": ["parent_comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_context_run_id_verify_runs_id_fk": {
+ "name": "acceptance_comments_context_run_id_verify_runs_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "verify_runs",
+ "columnsFrom": ["context_run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_evidence_id_verify_evidence_id_fk": {
+ "name": "acceptance_comments_evidence_id_verify_evidence_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "verify_evidence",
+ "columnsFrom": ["evidence_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "acceptance_comments_resolved_by_user_id_users_id_fk": {
+ "name": "acceptance_comments_resolved_by_user_id_users_id_fk",
+ "tableFrom": "acceptance_comments",
+ "tableTo": "users",
+ "columnsFrom": ["resolved_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.acceptance_flow_edges": {
+ "name": "acceptance_flow_edges",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "flow_id": {
+ "name": "flow_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_node_id": {
+ "name": "source_node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_node_id": {
+ "name": "target_node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "condition": {
+ "name": "condition",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "required": {
+ "name": "required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ }
+ },
+ "indexes": {
+ "acceptance_flow_edges_source_idx": {
+ "name": "acceptance_flow_edges_source_idx",
+ "columns": [
+ {
+ "expression": "flow_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_flow_edges_target_idx": {
+ "name": "acceptance_flow_edges_target_idx",
+ "columns": [
+ {
+ "expression": "flow_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "target_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_flow_edges_flow_id_acceptance_flows_id_fk": {
+ "name": "acceptance_flow_edges_flow_id_acceptance_flows_id_fk",
+ "tableFrom": "acceptance_flow_edges",
+ "tableTo": "acceptance_flows",
+ "columnsFrom": ["flow_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_flow_edges_flow_id_source_node_id_acceptance_flow_nodes_flow_id_id_fk": {
+ "name": "acceptance_flow_edges_flow_id_source_node_id_acceptance_flow_nodes_flow_id_id_fk",
+ "tableFrom": "acceptance_flow_edges",
+ "tableTo": "acceptance_flow_nodes",
+ "columnsFrom": ["flow_id", "source_node_id"],
+ "columnsTo": ["flow_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_flow_edges_flow_id_target_node_id_acceptance_flow_nodes_flow_id_id_fk": {
+ "name": "acceptance_flow_edges_flow_id_target_node_id_acceptance_flow_nodes_flow_id_id_fk",
+ "tableFrom": "acceptance_flow_edges",
+ "tableTo": "acceptance_flow_nodes",
+ "columnsFrom": ["flow_id", "target_node_id"],
+ "columnsTo": ["flow_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.acceptance_flow_nodes": {
+ "name": "acceptance_flow_nodes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "flow_id": {
+ "name": "flow_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "criterion_id": {
+ "name": "criterion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sub_flow_id": {
+ "name": "sub_flow_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_entry": {
+ "name": "is_entry",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "overrides": {
+ "name": "overrides",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "acceptance_flow_nodes_sub_flow_idx": {
+ "name": "acceptance_flow_nodes_sub_flow_idx",
+ "columns": [
+ {
+ "expression": "sub_flow_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_flow_nodes_flow_id_unique": {
+ "name": "acceptance_flow_nodes_flow_id_unique",
+ "columns": [
+ {
+ "expression": "flow_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_flow_nodes_entry_unique": {
+ "name": "acceptance_flow_nodes_entry_unique",
+ "columns": [
+ {
+ "expression": "flow_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"acceptance_flow_nodes\".\"is_entry\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptance_flow_nodes_criterion_idx": {
+ "name": "acceptance_flow_nodes_criterion_idx",
+ "columns": [
+ {
+ "expression": "criterion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_flow_nodes_flow_id_acceptance_flows_id_fk": {
+ "name": "acceptance_flow_nodes_flow_id_acceptance_flows_id_fk",
+ "tableFrom": "acceptance_flow_nodes",
+ "tableTo": "acceptance_flows",
+ "columnsFrom": ["flow_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptance_flow_nodes_criterion_id_verify_criteria_id_fk": {
+ "name": "acceptance_flow_nodes_criterion_id_verify_criteria_id_fk",
+ "tableFrom": "acceptance_flow_nodes",
+ "tableTo": "verify_criteria",
+ "columnsFrom": ["criterion_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "acceptance_flow_nodes_sub_flow_id_acceptance_flows_id_fk": {
+ "name": "acceptance_flow_nodes_sub_flow_id_acceptance_flows_id_fk",
+ "tableFrom": "acceptance_flow_nodes",
+ "tableTo": "acceptance_flows",
+ "columnsFrom": ["sub_flow_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "acceptance_flow_nodes_target_check": {
+ "name": "acceptance_flow_nodes_target_check",
+ "value": "num_nonnulls(\"acceptance_flow_nodes\".\"criterion_id\", \"acceptance_flow_nodes\".\"sub_flow_id\") = 1"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.acceptance_flows": {
+ "name": "acceptance_flows",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "acceptance_id": {
+ "name": "acceptance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "acceptance_flows_acceptance_idx": {
+ "name": "acceptance_flows_acceptance_idx",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptance_flows_acceptance_id_acceptances_id_fk": {
+ "name": "acceptance_flows_acceptance_id_acceptances_id_fk",
+ "tableFrom": "acceptance_flows",
+ "tableTo": "acceptances",
+ "columnsFrom": ["acceptance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agents": {
+ "name": "agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(1000)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'[]'::jsonb"
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_color": {
+ "name": "background_color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_identifier": {
+ "name": "market_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "profile": {
+ "name": "profile",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "society_id": {
+ "name": "society_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plugins": {
+ "name": "plugins",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agency_config": {
+ "name": "agency_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chat_config": {
+ "name": "chat_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "few_shots": {
+ "name": "few_shots",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "params": {
+ "name": "params",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_role": {
+ "name": "system_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tts": {
+ "name": "tts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "virtual": {
+ "name": "virtual",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "pinned": {
+ "name": "pinned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "opening_message": {
+ "name": "opening_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "opening_questions": {
+ "name": "opening_questions",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "session_group_id": {
+ "name": "session_group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "client_id_user_id_unique": {
+ "name": "client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_slug_user_id_unique": {
+ "name": "agents_slug_user_id_unique",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agents\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_created_at_idx": {
+ "name": "agents_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_user_id_idx": {
+ "name": "agents_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_title_idx": {
+ "name": "agents_title_idx",
+ "columns": [
+ {
+ "expression": "title",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_description_idx": {
+ "name": "agents_description_idx",
+ "columns": [
+ {
+ "expression": "description",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_session_group_id_idx": {
+ "name": "agents_session_group_id_idx",
+ "columns": [
+ {
+ "expression": "session_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_workspace_id_idx": {
+ "name": "agents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_workspace_visibility_idx": {
+ "name": "agents_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_slug_workspace_id_unique": {
+ "name": "agents_slug_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agents\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agents_user_id_users_id_fk": {
+ "name": "agents_user_id_users_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_workspace_id_workspaces_id_fk": {
+ "name": "agents_workspace_id_workspaces_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_session_group_id_session_groups_id_fk": {
+ "name": "agents_session_group_id_session_groups_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "session_groups",
+ "columnsFrom": ["session_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agents_files": {
+ "name": "agents_files",
+ "schema": "",
+ "columns": {
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agents_files_agent_id_idx": {
+ "name": "agents_files_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_files_file_id_idx": {
+ "name": "agents_files_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_files_user_id_idx": {
+ "name": "agents_files_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_files_workspace_id_idx": {
+ "name": "agents_files_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agents_files_file_id_files_id_fk": {
+ "name": "agents_files_file_id_files_id_fk",
+ "tableFrom": "agents_files",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_files_agent_id_agents_id_fk": {
+ "name": "agents_files_agent_id_agents_id_fk",
+ "tableFrom": "agents_files",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_files_user_id_users_id_fk": {
+ "name": "agents_files_user_id_users_id_fk",
+ "tableFrom": "agents_files",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_files_workspace_id_workspaces_id_fk": {
+ "name": "agents_files_workspace_id_workspaces_id_fk",
+ "tableFrom": "agents_files",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agents_files_file_id_agent_id_user_id_pk": {
+ "name": "agents_files_file_id_agent_id_user_id_pk",
+ "columns": ["file_id", "agent_id", "user_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agents_knowledge_bases": {
+ "name": "agents_knowledge_bases",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agents_knowledge_bases_agent_id_idx": {
+ "name": "agents_knowledge_bases_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_knowledge_bases_knowledge_base_id_idx": {
+ "name": "agents_knowledge_bases_knowledge_base_id_idx",
+ "columns": [
+ {
+ "expression": "knowledge_base_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_knowledge_bases_user_id_idx": {
+ "name": "agents_knowledge_bases_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_knowledge_bases_workspace_id_idx": {
+ "name": "agents_knowledge_bases_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agents_knowledge_bases_agent_id_agents_id_fk": {
+ "name": "agents_knowledge_bases_agent_id_agents_id_fk",
+ "tableFrom": "agents_knowledge_bases",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "agents_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "agents_knowledge_bases",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_knowledge_bases_user_id_users_id_fk": {
+ "name": "agents_knowledge_bases_user_id_users_id_fk",
+ "tableFrom": "agents_knowledge_bases",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_knowledge_bases_workspace_id_workspaces_id_fk": {
+ "name": "agents_knowledge_bases_workspace_id_workspaces_id_fk",
+ "tableFrom": "agents_knowledge_bases",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agents_knowledge_bases_agent_id_knowledge_base_id_pk": {
+ "name": "agents_knowledge_bases_agent_id_knowledge_base_id_pk",
+ "columns": ["agent_id", "knowledge_base_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_accounts": {
+ "name": "agent_accounts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'provisioning'"
+ },
+ "capabilities": {
+ "name": "capabilities",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_hint": {
+ "name": "credential_hint",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_accounts_agent_kind_provider_identifier_unique": {
+ "name": "agent_accounts_agent_kind_provider_identifier_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_accounts\".\"status\" <> 'revoked'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_accounts_provider_identifier_unique": {
+ "name": "agent_accounts_provider_identifier_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_accounts\".\"status\" <> 'revoked'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_accounts_agent_id_idx": {
+ "name": "agent_accounts_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_accounts_user_id_idx": {
+ "name": "agent_accounts_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_accounts_workspace_id_idx": {
+ "name": "agent_accounts_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_accounts_agent_id_agents_id_fk": {
+ "name": "agent_accounts_agent_id_agents_id_fk",
+ "tableFrom": "agent_accounts",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_accounts_user_id_users_id_fk": {
+ "name": "agent_accounts_user_id_users_id_fk",
+ "tableFrom": "agent_accounts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_accounts_workspace_id_workspaces_id_fk": {
+ "name": "agent_accounts_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_accounts",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_bot_providers": {
+ "name": "agent_bot_providers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "application_id": {
+ "name": "application_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_bot_providers_platform_app_id_unique": {
+ "name": "agent_bot_providers_platform_app_id_unique",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "application_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_bot_providers_platform_idx": {
+ "name": "agent_bot_providers_platform_idx",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_bot_providers_agent_id_idx": {
+ "name": "agent_bot_providers_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_bot_providers_user_id_idx": {
+ "name": "agent_bot_providers_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_bot_providers_workspace_id_idx": {
+ "name": "agent_bot_providers_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_bot_providers_agent_id_agents_id_fk": {
+ "name": "agent_bot_providers_agent_id_agents_id_fk",
+ "tableFrom": "agent_bot_providers",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_bot_providers_user_id_users_id_fk": {
+ "name": "agent_bot_providers_user_id_users_id_fk",
+ "tableFrom": "agent_bot_providers",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_bot_providers_workspace_id_workspaces_id_fk": {
+ "name": "agent_bot_providers_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_bot_providers",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_cron_jobs": {
+ "name": "agent_cron_jobs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "cron_pattern": {
+ "name": "cron_pattern",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'UTC'"
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "edit_data": {
+ "name": "edit_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_executions": {
+ "name": "max_executions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remaining_executions": {
+ "name": "remaining_executions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_conditions": {
+ "name": "execution_conditions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_executed_at": {
+ "name": "last_executed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_executions": {
+ "name": "total_executions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_cron_jobs_agent_id_idx": {
+ "name": "agent_cron_jobs_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_group_id_idx": {
+ "name": "agent_cron_jobs_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_user_id_idx": {
+ "name": "agent_cron_jobs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_workspace_id_idx": {
+ "name": "agent_cron_jobs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_enabled_idx": {
+ "name": "agent_cron_jobs_enabled_idx",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_remaining_executions_idx": {
+ "name": "agent_cron_jobs_remaining_executions_idx",
+ "columns": [
+ {
+ "expression": "remaining_executions",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_cron_jobs_last_executed_at_idx": {
+ "name": "agent_cron_jobs_last_executed_at_idx",
+ "columns": [
+ {
+ "expression": "last_executed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_cron_jobs_agent_id_agents_id_fk": {
+ "name": "agent_cron_jobs_agent_id_agents_id_fk",
+ "tableFrom": "agent_cron_jobs",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_cron_jobs_group_id_chat_groups_id_fk": {
+ "name": "agent_cron_jobs_group_id_chat_groups_id_fk",
+ "tableFrom": "agent_cron_jobs",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_cron_jobs_user_id_users_id_fk": {
+ "name": "agent_cron_jobs_user_id_users_id_fk",
+ "tableFrom": "agent_cron_jobs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_cron_jobs_workspace_id_workspaces_id_fk": {
+ "name": "agent_cron_jobs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_cron_jobs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_documents": {
+ "name": "agent_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "template_id": {
+ "name": "template_id",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_self": {
+ "name": "access_self",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 31
+ },
+ "access_shared": {
+ "name": "access_shared",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "access_public": {
+ "name": "access_public",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "policy_load": {
+ "name": "policy_load",
+ "type": "varchar(30)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'always'"
+ },
+ "policy": {
+ "name": "policy",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_load_position": {
+ "name": "policy_load_position",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'before-first-user'"
+ },
+ "policy_load_format": {
+ "name": "policy_load_format",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'raw'"
+ },
+ "policy_load_rule": {
+ "name": "policy_load_rule",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'always'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_by_user_id": {
+ "name": "deleted_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_by_agent_id": {
+ "name": "deleted_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delete_reason": {
+ "name": "delete_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_documents_workspace_id_idx": {
+ "name": "agent_documents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_user_id_idx": {
+ "name": "agent_documents_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_deleted_by_user_id_idx": {
+ "name": "agent_documents_deleted_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "deleted_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_agent_id_idx": {
+ "name": "agent_documents_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_access_self_idx": {
+ "name": "agent_documents_access_self_idx",
+ "columns": [
+ {
+ "expression": "access_self",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_access_shared_idx": {
+ "name": "agent_documents_access_shared_idx",
+ "columns": [
+ {
+ "expression": "access_shared",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_access_public_idx": {
+ "name": "agent_documents_access_public_idx",
+ "columns": [
+ {
+ "expression": "access_public",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_policy_load_idx": {
+ "name": "agent_documents_policy_load_idx",
+ "columns": [
+ {
+ "expression": "policy_load",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_template_id_idx": {
+ "name": "agent_documents_template_id_idx",
+ "columns": [
+ {
+ "expression": "template_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_policy_load_position_idx": {
+ "name": "agent_documents_policy_load_position_idx",
+ "columns": [
+ {
+ "expression": "policy_load_position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_policy_load_format_idx": {
+ "name": "agent_documents_policy_load_format_idx",
+ "columns": [
+ {
+ "expression": "policy_load_format",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_policy_load_rule_idx": {
+ "name": "agent_documents_policy_load_rule_idx",
+ "columns": [
+ {
+ "expression": "policy_load_rule",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_agent_load_position_idx": {
+ "name": "agent_documents_agent_load_position_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "policy_load_position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_deleted_at_idx": {
+ "name": "agent_documents_deleted_at_idx",
+ "columns": [
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_agent_autoload_deleted_idx": {
+ "name": "agent_documents_agent_autoload_deleted_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "policy_load",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_document_id_idx": {
+ "name": "agent_documents_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_documents_agent_document_user_unique": {
+ "name": "agent_documents_agent_document_user_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_documents_user_id_users_id_fk": {
+ "name": "agent_documents_user_id_users_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_documents_workspace_id_workspaces_id_fk": {
+ "name": "agent_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_documents_agent_id_agents_id_fk": {
+ "name": "agent_documents_agent_id_agents_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_documents_document_id_documents_id_fk": {
+ "name": "agent_documents_document_id_documents_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_documents_deleted_by_user_id_users_id_fk": {
+ "name": "agent_documents_deleted_by_user_id_users_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "users",
+ "columnsFrom": ["deleted_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_documents_deleted_by_agent_id_agents_id_fk": {
+ "name": "agent_documents_deleted_by_agent_id_agents_id_fk",
+ "tableFrom": "agent_documents",
+ "tableTo": "agents",
+ "columnsFrom": ["deleted_by_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_benchmarks": {
+ "name": "agent_eval_benchmarks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rubrics": {
+ "name": "rubrics",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_url": {
+ "name": "reference_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_system": {
+ "name": "is_system",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_benchmarks_identifier_user_id_unique": {
+ "name": "agent_eval_benchmarks_identifier_user_id_unique",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_benchmarks_is_system_idx": {
+ "name": "agent_eval_benchmarks_is_system_idx",
+ "columns": [
+ {
+ "expression": "is_system",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_benchmarks_user_id_idx": {
+ "name": "agent_eval_benchmarks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_benchmarks_workspace_id_idx": {
+ "name": "agent_eval_benchmarks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_benchmarks_identifier_workspace_id_unique": {
+ "name": "agent_eval_benchmarks_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_benchmarks\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_benchmarks_user_id_users_id_fk": {
+ "name": "agent_eval_benchmarks_user_id_users_id_fk",
+ "tableFrom": "agent_eval_benchmarks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_benchmarks_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_benchmarks_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_benchmarks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_datasets": {
+ "name": "agent_eval_datasets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "benchmark_id": {
+ "name": "benchmark_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_experiment_id": {
+ "name": "source_experiment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_mode": {
+ "name": "eval_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_config": {
+ "name": "eval_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_datasets_identifier_user_id_unique": {
+ "name": "agent_eval_datasets_identifier_user_id_unique",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_datasets\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_benchmark_id_idx": {
+ "name": "agent_eval_datasets_benchmark_id_idx",
+ "columns": [
+ {
+ "expression": "benchmark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_source_experiment_id_idx": {
+ "name": "agent_eval_datasets_source_experiment_id_idx",
+ "columns": [
+ {
+ "expression": "source_experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_user_id_idx": {
+ "name": "agent_eval_datasets_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_workspace_id_idx": {
+ "name": "agent_eval_datasets_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_datasets_identifier_workspace_id_unique": {
+ "name": "agent_eval_datasets_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_eval_datasets\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk": {
+ "name": "agent_eval_datasets_benchmark_id_agent_eval_benchmarks_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "agent_eval_benchmarks",
+ "columnsFrom": ["benchmark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk": {
+ "name": "agent_eval_datasets_source_experiment_id_agent_eval_experiments_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "agent_eval_experiments",
+ "columnsFrom": ["source_experiment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_eval_datasets_user_id_users_id_fk": {
+ "name": "agent_eval_datasets_user_id_users_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_datasets_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_datasets_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_datasets",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_experiment_benchmarks": {
+ "name": "agent_eval_experiment_benchmarks",
+ "schema": "",
+ "columns": {
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "benchmark_id": {
+ "name": "benchmark_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_experiment_benchmarks_benchmark_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_benchmark_id_idx",
+ "columns": [
+ {
+ "expression": "benchmark_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiment_benchmarks_user_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiment_benchmarks_workspace_id_idx": {
+ "name": "agent_eval_experiment_benchmarks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_experiment_id_agent_eval_experiments_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "agent_eval_experiments",
+ "columnsFrom": ["experiment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_benchmark_id_agent_eval_benchmarks_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "agent_eval_benchmarks",
+ "columnsFrom": ["benchmark_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_user_id_users_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_user_id_users_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_experiment_benchmarks_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_experiment_benchmarks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk": {
+ "name": "agent_eval_experiment_benchmarks_experiment_id_benchmark_id_pk",
+ "columns": ["experiment_id", "benchmark_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_experiments": {
+ "name": "agent_eval_experiments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_experiments_user_id_idx": {
+ "name": "agent_eval_experiments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_experiments_workspace_id_idx": {
+ "name": "agent_eval_experiments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_experiments_user_id_users_id_fk": {
+ "name": "agent_eval_experiments_user_id_users_id_fk",
+ "tableFrom": "agent_eval_experiments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_experiments_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_experiments_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_experiments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_run_topics": {
+ "name": "agent_eval_run_topics",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "test_case_id": {
+ "name": "test_case_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score": {
+ "name": "score",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "passed": {
+ "name": "passed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_result": {
+ "name": "eval_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_run_topics_user_id_idx": {
+ "name": "agent_eval_run_topics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_run_id_idx": {
+ "name": "agent_eval_run_topics_run_id_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_test_case_id_idx": {
+ "name": "agent_eval_run_topics_test_case_id_idx",
+ "columns": [
+ {
+ "expression": "test_case_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_run_topics_workspace_id_idx": {
+ "name": "agent_eval_run_topics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_run_topics_user_id_users_id_fk": {
+ "name": "agent_eval_run_topics_user_id_users_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_run_topics_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_run_id_agent_eval_runs_id_fk": {
+ "name": "agent_eval_run_topics_run_id_agent_eval_runs_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "agent_eval_runs",
+ "columnsFrom": ["run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_topic_id_topics_id_fk": {
+ "name": "agent_eval_run_topics_topic_id_topics_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk": {
+ "name": "agent_eval_run_topics_test_case_id_agent_eval_test_cases_id_fk",
+ "tableFrom": "agent_eval_run_topics",
+ "tableTo": "agent_eval_test_cases",
+ "columnsFrom": ["test_case_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_eval_run_topics_run_id_topic_id_pk": {
+ "name": "agent_eval_run_topics_run_id_topic_id_pk",
+ "columns": ["run_id", "topic_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_runs": {
+ "name": "agent_eval_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "dataset_id": {
+ "name": "dataset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "experiment_id": {
+ "name": "experiment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_run_id": {
+ "name": "parent_run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_agent_id": {
+ "name": "target_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metrics": {
+ "name": "metrics",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_runs_dataset_id_idx": {
+ "name": "agent_eval_runs_dataset_id_idx",
+ "columns": [
+ {
+ "expression": "dataset_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_experiment_id_idx": {
+ "name": "agent_eval_runs_experiment_id_idx",
+ "columns": [
+ {
+ "expression": "experiment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_parent_run_id_idx": {
+ "name": "agent_eval_runs_parent_run_id_idx",
+ "columns": [
+ {
+ "expression": "parent_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_user_id_idx": {
+ "name": "agent_eval_runs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_status_idx": {
+ "name": "agent_eval_runs_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_target_agent_id_idx": {
+ "name": "agent_eval_runs_target_agent_id_idx",
+ "columns": [
+ {
+ "expression": "target_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_runs_workspace_id_idx": {
+ "name": "agent_eval_runs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk": {
+ "name": "agent_eval_runs_dataset_id_agent_eval_datasets_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "agent_eval_datasets",
+ "columnsFrom": ["dataset_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk": {
+ "name": "agent_eval_runs_experiment_id_agent_eval_experiments_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "agent_eval_experiments",
+ "columnsFrom": ["experiment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "agent_eval_runs_target_agent_id_agents_id_fk": {
+ "name": "agent_eval_runs_target_agent_id_agents_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "agents",
+ "columnsFrom": ["target_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_runs_user_id_users_id_fk": {
+ "name": "agent_eval_runs_user_id_users_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_runs_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_runs_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk": {
+ "name": "agent_eval_runs_parent_run_id_agent_eval_runs_id_fk",
+ "tableFrom": "agent_eval_runs",
+ "tableTo": "agent_eval_runs",
+ "columnsFrom": ["parent_run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_eval_test_cases": {
+ "name": "agent_eval_test_cases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dataset_id": {
+ "name": "dataset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "eval_mode": {
+ "name": "eval_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_config": {
+ "name": "eval_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_eval_test_cases_user_id_idx": {
+ "name": "agent_eval_test_cases_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_test_cases_dataset_id_idx": {
+ "name": "agent_eval_test_cases_dataset_id_idx",
+ "columns": [
+ {
+ "expression": "dataset_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_test_cases_sort_order_idx": {
+ "name": "agent_eval_test_cases_sort_order_idx",
+ "columns": [
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_eval_test_cases_workspace_id_idx": {
+ "name": "agent_eval_test_cases_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_eval_test_cases_user_id_users_id_fk": {
+ "name": "agent_eval_test_cases_user_id_users_id_fk",
+ "tableFrom": "agent_eval_test_cases",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_test_cases_workspace_id_workspaces_id_fk": {
+ "name": "agent_eval_test_cases_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_eval_test_cases",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk": {
+ "name": "agent_eval_test_cases_dataset_id_agent_eval_datasets_id_fk",
+ "tableFrom": "agent_eval_test_cases",
+ "tableTo": "agent_eval_datasets",
+ "columnsFrom": ["dataset_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_history_job_agents": {
+ "name": "agent_history_job_agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "job_id": {
+ "name": "job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_history_job_agents_job_id_agent_id_unique": {
+ "name": "agent_history_job_agents_job_id_agent_id_unique",
+ "columns": [
+ {
+ "expression": "job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_job_agents_agent_id_idx": {
+ "name": "agent_history_job_agents_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_history_job_agents_job_id_agent_history_jobs_id_fk": {
+ "name": "agent_history_job_agents_job_id_agent_history_jobs_id_fk",
+ "tableFrom": "agent_history_job_agents",
+ "tableTo": "agent_history_jobs",
+ "columnsFrom": ["job_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_history_job_agents_agent_id_agents_id_fk": {
+ "name": "agent_history_job_agents_agent_id_agents_id_fk",
+ "tableFrom": "agent_history_job_agents",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_history_job_groups": {
+ "name": "agent_history_job_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "job_id": {
+ "name": "job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_history_job_groups_job_id_group_id_unique": {
+ "name": "agent_history_job_groups_job_id_group_id_unique",
+ "columns": [
+ {
+ "expression": "job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_job_groups_group_id_idx": {
+ "name": "agent_history_job_groups_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_history_job_groups_job_id_agent_history_jobs_id_fk": {
+ "name": "agent_history_job_groups_job_id_agent_history_jobs_id_fk",
+ "tableFrom": "agent_history_job_groups",
+ "tableTo": "agent_history_jobs",
+ "columnsFrom": ["job_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_history_job_groups_group_id_chat_groups_id_fk": {
+ "name": "agent_history_job_groups_group_id_chat_groups_id_fk",
+ "tableFrom": "agent_history_job_groups",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_history_job_topics": {
+ "name": "agent_history_job_topics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "job_id": {
+ "name": "job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority": {
+ "name": "priority",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "activity_at": {
+ "name": "activity_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "agent_history_job_topics_job_id_topic_id_unique": {
+ "name": "agent_history_job_topics_job_id_topic_id_unique",
+ "columns": [
+ {
+ "expression": "job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_job_topics_topic_id_idx": {
+ "name": "agent_history_job_topics_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_job_topics_pick_idx": {
+ "name": "agent_history_job_topics_pick_idx",
+ "columns": [
+ {
+ "expression": "job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "activity_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_history_job_topics_job_id_agent_history_jobs_id_fk": {
+ "name": "agent_history_job_topics_job_id_agent_history_jobs_id_fk",
+ "tableFrom": "agent_history_job_topics",
+ "tableTo": "agent_history_jobs",
+ "columnsFrom": ["job_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_history_job_topics_topic_id_topics_id_fk": {
+ "name": "agent_history_job_topics_topic_id_topics_id_fk",
+ "tableFrom": "agent_history_job_topics",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_history_jobs": {
+ "name": "agent_history_jobs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'transfer'"
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_ids": {
+ "name": "agent_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_ids": {
+ "name": "session_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_ids": {
+ "name": "group_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "source_user_id": {
+ "name": "source_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_workspace_id": {
+ "name": "source_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_user_id": {
+ "name": "target_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_workspace_id": {
+ "name": "target_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_topics": {
+ "name": "total_topics",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completed_topics": {
+ "name": "completed_topics",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_history_jobs_status_idx": {
+ "name": "agent_history_jobs_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_jobs_source_user_id_idx": {
+ "name": "agent_history_jobs_source_user_id_idx",
+ "columns": [
+ {
+ "expression": "source_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_jobs_target_user_id_idx": {
+ "name": "agent_history_jobs_target_user_id_idx",
+ "columns": [
+ {
+ "expression": "target_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_jobs_source_workspace_id_idx": {
+ "name": "agent_history_jobs_source_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "source_workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_history_jobs_target_workspace_id_idx": {
+ "name": "agent_history_jobs_target_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "target_workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_inbox_messages": {
+ "name": "agent_inbox_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sender": {
+ "name": "sender",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "preview": {
+ "name": "preview",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_key": {
+ "name": "thread_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "received_at": {
+ "name": "received_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "read_at": {
+ "name": "read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wake_claimed_at": {
+ "name": "wake_claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wait_consumed_by": {
+ "name": "wait_consumed_by",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_inbox_messages_source_unique": {
+ "name": "agent_inbox_messages_source_unique",
+ "columns": [
+ {
+ "expression": "source_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_agent_received_at_idx": {
+ "name": "agent_inbox_messages_agent_received_at_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "received_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_agent_created_at_idx": {
+ "name": "agent_inbox_messages_agent_created_at_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_account_created_at_idx": {
+ "name": "agent_inbox_messages_account_created_at_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_account_sender_created_at_idx": {
+ "name": "agent_inbox_messages_account_sender_created_at_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sender",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_account_thread_idx": {
+ "name": "agent_inbox_messages_account_thread_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_inbox_messages_user_id_idx": {
+ "name": "agent_inbox_messages_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_inbox_messages_agent_id_agents_id_fk": {
+ "name": "agent_inbox_messages_agent_id_agents_id_fk",
+ "tableFrom": "agent_inbox_messages",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_inbox_messages_user_id_users_id_fk": {
+ "name": "agent_inbox_messages_user_id_users_id_fk",
+ "tableFrom": "agent_inbox_messages",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_inbox_messages_workspace_id_workspaces_id_fk": {
+ "name": "agent_inbox_messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_inbox_messages",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_inbox_messages_account_id_agent_accounts_id_fk": {
+ "name": "agent_inbox_messages_account_id_agent_accounts_id_fk",
+ "tableFrom": "agent_inbox_messages",
+ "tableTo": "agent_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_inbox_messages_topic_id_topics_id_fk": {
+ "name": "agent_inbox_messages_topic_id_topics_id_fk",
+ "tableFrom": "agent_inbox_messages",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_intervention_resolutions": {
+ "name": "agent_intervention_resolutions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "resolution_request_id": {
+ "name": "resolution_request_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "batch_id": {
+ "name": "batch_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "selected_intervention_ids": {
+ "name": "selected_intervention_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_versions": {
+ "name": "expected_versions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_request_revision_hashes": {
+ "name": "expected_request_revision_hashes",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expected_item_count": {
+ "name": "expected_item_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "custom_execution_input_hash": {
+ "name": "custom_execution_input_hash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_execution_state": {
+ "name": "custom_execution_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_execution_attempt": {
+ "name": "custom_execution_attempt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_execution_lease_token": {
+ "name": "custom_execution_lease_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_execution_lease_expires_at": {
+ "name": "custom_execution_lease_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_execution_result": {
+ "name": "custom_execution_result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remember_tool_key": {
+ "name": "remember_tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "remember_effect_status": {
+ "name": "remember_effect_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_arguments": {
+ "name": "original_arguments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "edited_arguments": {
+ "name": "edited_arguments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "original_request_revision_hash": {
+ "name": "original_request_revision_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "edited_request_revision_hash": {
+ "name": "edited_request_revision_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "argument_effect_status": {
+ "name": "argument_effect_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'resolving'"
+ },
+ "resolving_at": {
+ "name": "resolving_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation_started_at": {
+ "name": "continuation_started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "producer_ack_at": {
+ "name": "producer_ack_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "terminal_at": {
+ "name": "terminal_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rolled_back_at": {
+ "name": "rolled_back_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_intervention_resolutions_request_unique": {
+ "name": "agent_intervention_resolutions_request_unique",
+ "columns": [
+ {
+ "expression": "resolution_request_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_intervention_resolutions_owner_batch_idx": {
+ "name": "agent_intervention_resolutions_owner_batch_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_intervention_resolutions_status_created_idx": {
+ "name": "agent_intervention_resolutions_status_created_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_intervention_resolutions_operation_id_agent_operations_id_fk": {
+ "name": "agent_intervention_resolutions_operation_id_agent_operations_id_fk",
+ "tableFrom": "agent_intervention_resolutions",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_intervention_resolutions_user_id_users_id_fk": {
+ "name": "agent_intervention_resolutions_user_id_users_id_fk",
+ "tableFrom": "agent_intervention_resolutions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_intervention_resolutions_workspace_id_workspaces_id_fk": {
+ "name": "agent_intervention_resolutions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_intervention_resolutions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_intervention_resolutions_expected_item_count_check": {
+ "name": "agent_intervention_resolutions_expected_item_count_check",
+ "value": "\"agent_intervention_resolutions\".\"expected_item_count\" > 0"
+ },
+ "agent_intervention_resolutions_custom_execution_input_hash_check": {
+ "name": "agent_intervention_resolutions_custom_execution_input_hash_check",
+ "value": "\"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL OR \"agent_intervention_resolutions\".\"custom_execution_input_hash\" ~ '^[a-f0-9]{64}$'"
+ },
+ "agent_intervention_resolutions_custom_execution_state_check": {
+ "name": "agent_intervention_resolutions_custom_execution_state_check",
+ "value": "(\n (\"agent_intervention_resolutions\".\"custom_execution_state\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'pending'\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" = 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'executing'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NULL)\n OR\n (\"agent_intervention_resolutions\".\"custom_execution_state\" = 'completed'\n AND \"agent_intervention_resolutions\".\"custom_execution_input_hash\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_attempt\" > 0\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_token\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_lease_expires_at\" IS NOT NULL\n AND \"agent_intervention_resolutions\".\"custom_execution_result\" IS NOT NULL)\n )"
+ },
+ "agent_intervention_resolutions_custom_execution_parent_status_check": {
+ "name": "agent_intervention_resolutions_custom_execution_parent_status_check",
+ "value": "\"agent_intervention_resolutions\".\"custom_execution_state\" NOT IN ('executing', 'completed') OR \"agent_intervention_resolutions\".\"status\" IN ('resolving', 'published', 'acknowledged', 'completed')"
+ },
+ "agent_intervention_resolutions_version_check": {
+ "name": "agent_intervention_resolutions_version_check",
+ "value": "\"agent_intervention_resolutions\".\"version\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_interventions": {
+ "name": "agent_interventions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_message_id": {
+ "name": "tool_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interaction_kind": {
+ "name": "interaction_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "system_action_eligibility": {
+ "name": "system_action_eligibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approval_mode": {
+ "name": "approval_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "batch_id": {
+ "name": "batch_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "activity_key": {
+ "name": "activity_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step_index": {
+ "name": "step_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "item_index": {
+ "name": "item_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "item_count": {
+ "name": "item_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sealed": {
+ "name": "sealed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "canonical_tool_key": {
+ "name": "canonical_tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "request_revision_hash": {
+ "name": "request_revision_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allowed_actions": {
+ "name": "allowed_actions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "risk": {
+ "name": "risk",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_token_hash": {
+ "name": "review_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "review_context": {
+ "name": "review_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sanitized_request": {
+ "name": "sanitized_request",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deadline": {
+ "name": "deadline",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "resolution_id": {
+ "name": "resolution_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolving_at": {
+ "name": "resolving_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "producer_ack_at": {
+ "name": "producer_ack_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_interventions_operation_batch_tool_call_unique": {
+ "name": "agent_interventions_operation_batch_tool_call_unique",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_call_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_review_token_hash_unique": {
+ "name": "agent_interventions_review_token_hash_unique",
+ "columns": [
+ {
+ "expression": "review_token_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_operation_batch_item_unique": {
+ "name": "agent_interventions_operation_batch_item_unique",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "item_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_owner_activity_item_unique": {
+ "name": "agent_interventions_owner_activity_item_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "activity_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "item_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_owner_status_deadline_idx": {
+ "name": "agent_interventions_owner_status_deadline_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deadline",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_owner_batch_idx": {
+ "name": "agent_interventions_owner_batch_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "item_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_activity_key_idx": {
+ "name": "agent_interventions_activity_key_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "activity_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_interventions_status_deadline_idx": {
+ "name": "agent_interventions_status_deadline_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deadline",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_interventions_operation_id_agent_operations_id_fk": {
+ "name": "agent_interventions_operation_id_agent_operations_id_fk",
+ "tableFrom": "agent_interventions",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_interventions_user_id_users_id_fk": {
+ "name": "agent_interventions_user_id_users_id_fk",
+ "tableFrom": "agent_interventions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_interventions_workspace_id_workspaces_id_fk": {
+ "name": "agent_interventions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_interventions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk": {
+ "name": "agent_interventions_resolution_id_agent_intervention_resolutions_id_fk",
+ "tableFrom": "agent_interventions",
+ "tableTo": "agent_intervention_resolutions",
+ "columnsFrom": ["resolution_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_interventions_review_token_hash_check": {
+ "name": "agent_interventions_review_token_hash_check",
+ "value": "\"agent_interventions\".\"review_token_hash\" ~ '^[a-f0-9]{64}$'"
+ },
+ "agent_interventions_request_revision_hash_check": {
+ "name": "agent_interventions_request_revision_hash_check",
+ "value": "\"agent_interventions\".\"request_revision_hash\" ~ '^[a-f0-9]{64}$'"
+ },
+ "agent_interventions_step_index_check": {
+ "name": "agent_interventions_step_index_check",
+ "value": "\"agent_interventions\".\"step_index\" >= 0"
+ },
+ "agent_interventions_item_bounds_check": {
+ "name": "agent_interventions_item_bounds_check",
+ "value": "\"agent_interventions\".\"item_count\" > 0 AND \"agent_interventions\".\"item_index\" >= 0 AND \"agent_interventions\".\"item_index\" < \"agent_interventions\".\"item_count\""
+ },
+ "agent_interventions_version_check": {
+ "name": "agent_interventions_version_check",
+ "value": "\"agent_interventions\".\"version\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_label_assignments": {
+ "name": "agent_label_assignments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_label_assignments_label_id_agent_id_unique": {
+ "name": "agent_label_assignments_label_id_agent_id_unique",
+ "columns": [
+ {
+ "expression": "label_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_label_assignments_agent_id_idx": {
+ "name": "agent_label_assignments_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_label_assignments_user_id_idx": {
+ "name": "agent_label_assignments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_label_assignments_workspace_id_idx": {
+ "name": "agent_label_assignments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_label_assignments_label_id_agent_labels_id_fk": {
+ "name": "agent_label_assignments_label_id_agent_labels_id_fk",
+ "tableFrom": "agent_label_assignments",
+ "tableTo": "agent_labels",
+ "columnsFrom": ["label_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_label_assignments_agent_id_agents_id_fk": {
+ "name": "agent_label_assignments_agent_id_agents_id_fk",
+ "tableFrom": "agent_label_assignments",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_label_assignments_user_id_users_id_fk": {
+ "name": "agent_label_assignments_user_id_users_id_fk",
+ "tableFrom": "agent_label_assignments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_label_assignments_workspace_id_workspaces_id_fk": {
+ "name": "agent_label_assignments_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_label_assignments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_labels": {
+ "name": "agent_labels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived": {
+ "name": "archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_labels_user_id_idx": {
+ "name": "agent_labels_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_labels_workspace_id_idx": {
+ "name": "agent_labels_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_labels_user_id_name_unique": {
+ "name": "agent_labels_user_id_name_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_labels\".\"workspace_id\" IS NULL AND \"agent_labels\".\"archived\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_labels_workspace_id_name_unique": {
+ "name": "agent_labels_workspace_id_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_labels\".\"workspace_id\" IS NOT NULL AND \"agent_labels\".\"archived\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_labels_user_id_users_id_fk": {
+ "name": "agent_labels_user_id_users_id_fk",
+ "tableFrom": "agent_labels",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_labels_workspace_id_workspaces_id_fk": {
+ "name": "agent_labels_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_labels",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_mails": {
+ "name": "agent_mails",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "signal_id": {
+ "name": "signal_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "direction": {
+ "name": "direction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_message_id": {
+ "name": "provider_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "in_reply_to": {
+ "name": "in_reply_to",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "references": {
+ "name": "references",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "thread_key": {
+ "name": "thread_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from_address": {
+ "name": "from_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "from_name": {
+ "name": "from_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to": {
+ "name": "to",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "cc": {
+ "name": "cc",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "reply_to": {
+ "name": "reply_to",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "attachments": {
+ "name": "attachments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "codes": {
+ "name": "codes",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "delivered_at": {
+ "name": "delivered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_mails_account_provider_message_unique": {
+ "name": "agent_mails_account_provider_message_unique",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_mails_account_thread_idx": {
+ "name": "agent_mails_account_thread_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_mails_agent_delivered_at_idx": {
+ "name": "agent_mails_agent_delivered_at_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "delivered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_mails_signal_id_idx": {
+ "name": "agent_mails_signal_id_idx",
+ "columns": [
+ {
+ "expression": "signal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_mails_user_id_idx": {
+ "name": "agent_mails_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_mails_agent_id_agents_id_fk": {
+ "name": "agent_mails_agent_id_agents_id_fk",
+ "tableFrom": "agent_mails",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_mails_user_id_users_id_fk": {
+ "name": "agent_mails_user_id_users_id_fk",
+ "tableFrom": "agent_mails",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_mails_workspace_id_workspaces_id_fk": {
+ "name": "agent_mails_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_mails",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_mails_account_id_agent_accounts_id_fk": {
+ "name": "agent_mails_account_id_agent_accounts_id_fk",
+ "tableFrom": "agent_mails",
+ "tableTo": "agent_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_mails_signal_id_signals_id_fk": {
+ "name": "agent_mails_signal_id_signals_id_fk",
+ "tableFrom": "agent_mails",
+ "tableTo": "signals",
+ "columnsFrom": ["signal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_operations": {
+ "name": "agent_operations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chat_group_id": {
+ "name": "chat_group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_operation_id": {
+ "name": "parent_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "completion_reason": {
+ "name": "completion_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_status": {
+ "name": "verify_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_plan": {
+ "name": "verify_plan",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verify_plan_confirmed_at": {
+ "name": "verify_plan_confirmed_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
+ },
+ "step_count": {
+ "name": "step_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "force_finish": {
+ "name": "force_finish",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interruption": {
+ "name": "interruption",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "currency": {
+ "name": "currency",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'USD'"
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens": {
+ "name": "total_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "llm_calls": {
+ "name": "llm_calls",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_calls": {
+ "name": "tool_calls",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "human_interventions": {
+ "name": "human_interventions",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processing_time_ms": {
+ "name": "processing_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "human_waiting_time_ms": {
+ "name": "human_waiting_time_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage": {
+ "name": "usage",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_limit": {
+ "name": "cost_limit",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_runtime_config": {
+ "name": "model_runtime_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_context": {
+ "name": "app_context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trace_s3_key": {
+ "name": "trace_s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_operations_user_id_idx": {
+ "name": "agent_operations_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_workspace_id_idx": {
+ "name": "agent_operations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_agent_id_idx": {
+ "name": "agent_operations_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_topic_id_idx": {
+ "name": "agent_operations_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_thread_id_idx": {
+ "name": "agent_operations_thread_id_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_task_id_idx": {
+ "name": "agent_operations_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_chat_group_id_idx": {
+ "name": "agent_operations_chat_group_id_idx",
+ "columns": [
+ {
+ "expression": "chat_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_parent_operation_id_idx": {
+ "name": "agent_operations_parent_operation_id_idx",
+ "columns": [
+ {
+ "expression": "parent_operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_status_idx": {
+ "name": "agent_operations_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_user_id_created_at_idx": {
+ "name": "agent_operations_user_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_operations_metadata_idx": {
+ "name": "agent_operations_metadata_idx",
+ "columns": [
+ {
+ "expression": "metadata",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_operations_workspace_id_workspaces_id_fk": {
+ "name": "agent_operations_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_operations_agent_id_agents_id_fk": {
+ "name": "agent_operations_agent_id_agents_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_operations_topic_id_topics_id_fk": {
+ "name": "agent_operations_topic_id_topics_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_operations_thread_id_threads_id_fk": {
+ "name": "agent_operations_thread_id_threads_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "threads",
+ "columnsFrom": ["thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_operations_task_id_tasks_id_fk": {
+ "name": "agent_operations_task_id_tasks_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_operations_chat_group_id_chat_groups_id_fk": {
+ "name": "agent_operations_chat_group_id_chat_groups_id_fk",
+ "tableFrom": "agent_operations",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["chat_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_account_bindings": {
+ "name": "agent_account_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pool'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "weight": {
+ "name": "weight",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_account_bindings_agent_account_unique": {
+ "name": "agent_account_bindings_agent_account_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_account_bindings_agent_pinned_unique": {
+ "name": "agent_account_bindings_agent_pinned_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_account_bindings\".\"role\" = 'pinned'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_account_bindings_agent_id_idx": {
+ "name": "agent_account_bindings_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_account_bindings_account_id_idx": {
+ "name": "agent_account_bindings_account_id_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_account_bindings_user_id_idx": {
+ "name": "agent_account_bindings_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_account_bindings_workspace_id_idx": {
+ "name": "agent_account_bindings_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_account_bindings_agent_id_agents_id_fk": {
+ "name": "agent_account_bindings_agent_id_agents_id_fk",
+ "tableFrom": "agent_account_bindings",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_account_bindings_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_account_bindings_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_account_bindings",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_account_bindings_user_id_users_id_fk": {
+ "name": "agent_account_bindings_user_id_users_id_fk",
+ "tableFrom": "agent_account_bindings",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_account_bindings_workspace_id_workspaces_id_fk": {
+ "name": "agent_account_bindings_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_account_bindings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_provider_accounts": {
+ "name": "agent_provider_accounts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_account_id": {
+ "name": "external_account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_tier": {
+ "name": "plan_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rate_limit_tier": {
+ "name": "rate_limit_tier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "label": {
+ "name": "label",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_mode": {
+ "name": "credential_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'referenced'"
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_ref": {
+ "name": "credential_ref",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "last_validated_at": {
+ "name": "last_validated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_provider_accounts_user_id_idx": {
+ "name": "agent_provider_accounts_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_accounts_workspace_id_idx": {
+ "name": "agent_provider_accounts_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_accounts_token_expires_at_idx": {
+ "name": "agent_provider_accounts_token_expires_at_idx",
+ "columns": [
+ {
+ "expression": "token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_accounts_identity_unique": {
+ "name": "agent_provider_accounts_identity_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_provider_accounts_identity_workspace_unique": {
+ "name": "agent_provider_accounts_identity_workspace_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_provider_accounts\".\"external_account_id\" IS NOT NULL and \"agent_provider_accounts\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_provider_accounts_user_id_users_id_fk": {
+ "name": "agent_provider_accounts_user_id_users_id_fk",
+ "tableFrom": "agent_provider_accounts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_provider_accounts_workspace_id_workspaces_id_fk": {
+ "name": "agent_provider_accounts_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_provider_accounts",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_quota_calibrations": {
+ "name": "agent_quota_calibrations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_key": {
+ "name": "scope_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "capacity_usd": {
+ "name": "capacity_usd",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "capacity_tokens_equivalent": {
+ "name": "capacity_tokens_equivalent",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model_mix": {
+ "name": "model_mix",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sample_count": {
+ "name": "sample_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "window_seconds": {
+ "name": "window_seconds",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "calibrated_at": {
+ "name": "calibrated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_quota_calibrations_account_type_scope_idx": {
+ "name": "agent_quota_calibrations_account_type_scope_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "limit_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "calibrated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_calibrations_workspace_id_idx": {
+ "name": "agent_quota_calibrations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_calibrations_user_id_idx": {
+ "name": "agent_quota_calibrations_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_quota_calibrations_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_quota_calibrations",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_calibrations_user_id_users_id_fk": {
+ "name": "agent_quota_calibrations_user_id_users_id_fk",
+ "tableFrom": "agent_quota_calibrations",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_calibrations_workspace_id_workspaces_id_fk": {
+ "name": "agent_quota_calibrations_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_quota_calibrations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_quota_snapshots": {
+ "name": "agent_quota_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_key": {
+ "name": "scope_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "resets_at": {
+ "name": "resets_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "utilization": {
+ "name": "utilization",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "raw": {
+ "name": "raw",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_quota_snapshots_account_type_scope_idx": {
+ "name": "agent_quota_snapshots_account_type_scope_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "limit_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "captured_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_snapshots_account_captured_idx": {
+ "name": "agent_quota_snapshots_account_captured_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "captured_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_snapshots_resets_at_idx": {
+ "name": "agent_quota_snapshots_resets_at_idx",
+ "columns": [
+ {
+ "expression": "resets_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_snapshots_workspace_id_idx": {
+ "name": "agent_quota_snapshots_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_snapshots_user_id_idx": {
+ "name": "agent_quota_snapshots_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_quota_snapshots_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_quota_snapshots",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_snapshots_user_id_users_id_fk": {
+ "name": "agent_quota_snapshots_user_id_users_id_fk",
+ "tableFrom": "agent_quota_snapshots",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_snapshots_workspace_id_workspaces_id_fk": {
+ "name": "agent_quota_snapshots_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_quota_snapshots",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_snapshots_device_id_devices_id_fk": {
+ "name": "agent_quota_snapshots_device_id_devices_id_fk",
+ "tableFrom": "agent_quota_snapshots",
+ "tableTo": "devices",
+ "columnsFrom": ["device_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_quota_usage_ledger": {
+ "name": "agent_quota_usage_ledger",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_read_tokens": {
+ "name": "cache_read_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_write_tokens": {
+ "name": "cache_write_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning_tokens": {
+ "name": "reasoning_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_usd": {
+ "name": "cost_usd",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_source": {
+ "name": "cost_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_event_id": {
+ "name": "external_event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_quota_usage_ledger_account_occurred_idx": {
+ "name": "agent_quota_usage_ledger_account_occurred_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_account_model_occurred_idx": {
+ "name": "agent_quota_usage_ledger_account_model_occurred_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "occurred_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_message_id_idx": {
+ "name": "agent_quota_usage_ledger_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_operation_id_idx": {
+ "name": "agent_quota_usage_ledger_operation_id_idx",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_workspace_id_idx": {
+ "name": "agent_quota_usage_ledger_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_user_id_idx": {
+ "name": "agent_quota_usage_ledger_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_usage_ledger_external_event_unique": {
+ "name": "agent_quota_usage_ledger_external_event_unique",
+ "columns": [
+ {
+ "expression": "external_event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_quota_usage_ledger\".\"external_event_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_quota_usage_ledger_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_user_id_users_id_fk": {
+ "name": "agent_quota_usage_ledger_user_id_users_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_workspace_id_workspaces_id_fk": {
+ "name": "agent_quota_usage_ledger_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_message_id_messages_id_fk": {
+ "name": "agent_quota_usage_ledger_message_id_messages_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_operation_id_agent_operations_id_fk": {
+ "name": "agent_quota_usage_ledger_operation_id_agent_operations_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_topic_id_topics_id_fk": {
+ "name": "agent_quota_usage_ledger_topic_id_topics_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_quota_usage_ledger_agent_id_agents_id_fk": {
+ "name": "agent_quota_usage_ledger_agent_id_agents_id_fk",
+ "tableFrom": "agent_quota_usage_ledger",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_quota_windows": {
+ "name": "agent_quota_windows",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "limit_type": {
+ "name": "limit_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_key": {
+ "name": "scope_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "resets_at": {
+ "name": "resets_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_start_at": {
+ "name": "window_start_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_seconds": {
+ "name": "window_seconds",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "peak_utilization": {
+ "name": "peak_utilization",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_utilization": {
+ "name": "last_utilization",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rate_limited_at": {
+ "name": "rate_limited_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "observed_cost_usd": {
+ "name": "observed_cost_usd",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "observed_tokens": {
+ "name": "observed_tokens",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimated_capacity_usd": {
+ "name": "estimated_capacity_usd",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contaminated": {
+ "name": "contaminated",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_quota_windows_natural_key_unique": {
+ "name": "agent_quota_windows_natural_key_unique",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "limit_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scope_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resets_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_windows_account_resets_idx": {
+ "name": "agent_quota_windows_account_resets_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resets_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_windows_user_id_idx": {
+ "name": "agent_quota_windows_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_quota_windows_workspace_id_idx": {
+ "name": "agent_quota_windows_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_quota_windows_account_id_agent_provider_accounts_id_fk": {
+ "name": "agent_quota_windows_account_id_agent_provider_accounts_id_fk",
+ "tableFrom": "agent_quota_windows",
+ "tableTo": "agent_provider_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_windows_user_id_users_id_fk": {
+ "name": "agent_quota_windows_user_id_users_id_fk",
+ "tableFrom": "agent_quota_windows",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_quota_windows_workspace_id_workspaces_id_fk": {
+ "name": "agent_quota_windows_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_quota_windows",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_shares": {
+ "name": "agent_shares",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "share_config": {
+ "name": "share_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_view_count": {
+ "name": "user_view_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_shares_agent_id_unique": {
+ "name": "agent_shares_agent_id_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_shares_visibility_idx": {
+ "name": "agent_shares_visibility_idx",
+ "columns": [
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_shares_agent_id_agents_id_fk": {
+ "name": "agent_shares_agent_id_agents_id_fk",
+ "tableFrom": "agent_shares",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_skills": {
+ "name": "agent_skills",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "zip_file_hash": {
+ "name": "zip_file_hash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_skills_user_name_idx": {
+ "name": "agent_skills_user_name_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_skills\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_identifier_idx": {
+ "name": "agent_skills_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_user_id_idx": {
+ "name": "agent_skills_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_source_idx": {
+ "name": "agent_skills_source_idx",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_zip_hash_idx": {
+ "name": "agent_skills_zip_hash_idx",
+ "columns": [
+ {
+ "expression": "zip_file_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_workspace_id_idx": {
+ "name": "agent_skills_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_skills_name_workspace_id_unique": {
+ "name": "agent_skills_name_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"agent_skills\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skills_zip_file_hash_global_files_hash_id_fk": {
+ "name": "agent_skills_zip_file_hash_global_files_hash_id_fk",
+ "tableFrom": "agent_skills",
+ "tableTo": "global_files",
+ "columnsFrom": ["zip_file_hash"],
+ "columnsTo": ["hash_id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "agent_skills_user_id_users_id_fk": {
+ "name": "agent_skills_user_id_users_id_fk",
+ "tableFrom": "agent_skills",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_skills_workspace_id_workspaces_id_fk": {
+ "name": "agent_skills_workspace_id_workspaces_id_fk",
+ "tableFrom": "agent_skills",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_models": {
+ "name": "ai_models",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(150)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "_id": {
+ "name": "_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "varchar(200)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization": {
+ "name": "organization",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'chat'"
+ },
+ "sort": {
+ "name": "sort",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pricing": {
+ "name": "pricing",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parameters": {
+ "name": "parameters",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abilities": {
+ "name": "abilities",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "context_window_tokens": {
+ "name": "context_window_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "released_at": {
+ "name": "released_at",
+ "type": "varchar(10)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_models_id_provider_id_user_id_unique": {
+ "name": "ai_models_id_provider_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"ai_models\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_models_id_provider_id_user_id_workspace_id_unique": {
+ "name": "ai_models_id_provider_id_user_id_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"ai_models\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_models_user_id_idx": {
+ "name": "ai_models_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_models_workspace_id_idx": {
+ "name": "ai_models_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_models_user_id_users_id_fk": {
+ "name": "ai_models_user_id_users_id_fk",
+ "tableFrom": "ai_models",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_models_workspace_id_workspaces_id_fk": {
+ "name": "ai_models_workspace_id_workspaces_id_fk",
+ "tableFrom": "ai_models",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_providers": {
+ "name": "ai_providers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "_id": {
+ "name": "_id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sort": {
+ "name": "sort",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fetch_on_client": {
+ "name": "fetch_on_client",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_model": {
+ "name": "check_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_vaults": {
+ "name": "key_vaults",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_providers_id_user_id_unique": {
+ "name": "ai_providers_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"ai_providers\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_providers_id_user_id_workspace_id_unique": {
+ "name": "ai_providers_id_user_id_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"ai_providers\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_providers_user_id_idx": {
+ "name": "ai_providers_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_providers_workspace_id_idx": {
+ "name": "ai_providers_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_providers_user_id_users_id_fk": {
+ "name": "ai_providers_user_id_users_id_fk",
+ "tableFrom": "ai_providers",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_providers_workspace_id_workspaces_id_fk": {
+ "name": "ai_providers_workspace_id_workspaces_id_fk",
+ "tableFrom": "ai_providers",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.api_keys": {
+ "name": "api_keys",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(256)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "varchar(256)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_hash": {
+ "name": "key_hash",
+ "type": "varchar(128)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "api_keys_user_id_idx": {
+ "name": "api_keys_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "api_keys_workspace_id_idx": {
+ "name": "api_keys_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "api_keys_user_id_users_id_fk": {
+ "name": "api_keys_user_id_users_id_fk",
+ "tableFrom": "api_keys",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "api_keys_workspace_id_workspaces_id_fk": {
+ "name": "api_keys_workspace_id_workspaces_id_fk",
+ "tableFrom": "api_keys",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "api_keys_key_unique": {
+ "name": "api_keys_key_unique",
+ "nullsNotDistinct": false,
+ "columns": ["key"]
+ },
+ "api_keys_key_hash_unique": {
+ "name": "api_keys_key_hash_unique",
+ "nullsNotDistinct": false,
+ "columns": ["key_hash"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.async_tasks": {
+ "name": "async_tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "inference_id": {
+ "name": "inference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "async_tasks_user_id_idx": {
+ "name": "async_tasks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_parent_id_idx": {
+ "name": "async_tasks_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_type_status_idx": {
+ "name": "async_tasks_type_status_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_inference_id_idx": {
+ "name": "async_tasks_inference_id_idx",
+ "columns": [
+ {
+ "expression": "inference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "async_tasks_metadata_idx": {
+ "name": "async_tasks_metadata_idx",
+ "columns": [
+ {
+ "expression": "metadata",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ },
+ "async_tasks_workspace_id_idx": {
+ "name": "async_tasks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "async_tasks_user_id_users_id_fk": {
+ "name": "async_tasks_user_id_users_id_fk",
+ "tableFrom": "async_tasks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "async_tasks_workspace_id_workspaces_id_fk": {
+ "name": "async_tasks_workspace_id_workspaces_id_fk",
+ "tableFrom": "async_tasks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.accounts": {
+ "name": "accounts",
+ "schema": "",
+ "columns": {
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "accounts_user_id_users_id_fk": {
+ "name": "accounts_user_id_users_id_fk",
+ "tableFrom": "accounts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backedUp": {
+ "name": "backedUp",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "credentialID": {
+ "name": "credentialID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deviceType": {
+ "name": "deviceType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "publicKey": {
+ "name": "publicKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "passkey_credential_id_unique": {
+ "name": "passkey_credential_id_unique",
+ "columns": [
+ {
+ "expression": "credentialID",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_user_id_idx": {
+ "name": "passkey_user_id_idx",
+ "columns": [
+ {
+ "expression": "userId",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_userId_users_id_fk": {
+ "name": "passkey_userId_users_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "users",
+ "columnsFrom": ["userId"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.auth_sessions": {
+ "name": "auth_sessions",
+ "schema": "",
+ "columns": {
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "impersonated_by": {
+ "name": "impersonated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "auth_session_userId_idx": {
+ "name": "auth_session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "auth_sessions_user_id_users_id_fk": {
+ "name": "auth_sessions_user_id_users_id_fk",
+ "tableFrom": "auth_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "auth_sessions_token_unique": {
+ "name": "auth_sessions_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.two_factor": {
+ "name": "two_factor",
+ "schema": "",
+ "columns": {
+ "backup_codes": {
+ "name": "backup_codes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "two_factor_secret_idx": {
+ "name": "two_factor_secret_idx",
+ "columns": [
+ {
+ "expression": "secret",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "two_factor_user_id_idx": {
+ "name": "two_factor_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "two_factor_user_id_users_id_fk": {
+ "name": "two_factor_user_id_users_id_fk",
+ "tableFrom": "two_factor",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verifications": {
+ "name": "verifications",
+ "schema": "",
+ "columns": {
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_audit": {
+ "name": "channel_audit",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event": {
+ "name": "event",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "details": {
+ "name": "details",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channel_audit_channel_event_idx": {
+ "name": "channel_audit_channel_event_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_audit_target_event_idx": {
+ "name": "channel_audit_target_event_idx",
+ "columns": [
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_audit_channel_id_channels_id_fk": {
+ "name": "channel_audit_channel_id_channels_id_fk",
+ "tableFrom": "channel_audit",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_jobs": {
+ "name": "channel_jobs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_id": {
+ "name": "member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requester_member_id": {
+ "name": "requester_member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delivery_key": {
+ "name": "delivery_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'initial'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "blocked_reason": {
+ "name": "blocked_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "blocked_code": {
+ "name": "blocked_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "claimed_at": {
+ "name": "claimed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "execution_config": {
+ "name": "execution_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "working_directory": {
+ "name": "working_directory",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_at": {
+ "name": "accepted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_owner": {
+ "name": "lease_owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_expires_at": {
+ "name": "lease_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "writer_held": {
+ "name": "writer_held",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "isolated_at": {
+ "name": "isolated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft": {
+ "name": "draft",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "publication_revoked": {
+ "name": "publication_revoked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "published_message_id": {
+ "name": "published_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channel_jobs_delivery_unique": {
+ "name": "channel_jobs_delivery_unique",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "delivery_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_channel_status_idx": {
+ "name": "channel_jobs_channel_status_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_continuation_idx": {
+ "name": "channel_jobs_continuation_idx",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "requester_member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "claimed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_topic_idx": {
+ "name": "channel_jobs_topic_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "published_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_member_queue_idx": {
+ "name": "channel_jobs_member_queue_idx",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_lease_expires_idx": {
+ "name": "channel_jobs_lease_expires_idx",
+ "columns": [
+ {
+ "expression": "lease_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_active_member_unique": {
+ "name": "channel_jobs_active_member_unique",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"channel_jobs\".\"writer_held\" AND \"channel_jobs\".\"isolated_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_jobs_active_directory_unique": {
+ "name": "channel_jobs_active_directory_unique",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "working_directory",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"channel_jobs\".\"device_id\" IS NOT NULL AND \"channel_jobs\".\"working_directory\" IS NOT NULL AND \"channel_jobs\".\"writer_held\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_jobs_channel_id_channels_id_fk": {
+ "name": "channel_jobs_channel_id_channels_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_topic_id_topics_id_fk": {
+ "name": "channel_jobs_topic_id_topics_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_operation_id_agent_operations_id_fk": {
+ "name": "channel_jobs_operation_id_agent_operations_id_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_member_fk": {
+ "name": "channel_jobs_member_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_requester_fk": {
+ "name": "channel_jobs_requester_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "requester_member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_message_fk": {
+ "name": "channel_jobs_message_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["channel_id", "message_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_jobs_thread_fk": {
+ "name": "channel_jobs_thread_fk",
+ "tableFrom": "channel_jobs",
+ "tableTo": "channel_threads",
+ "columnsFrom": ["channel_id", "thread_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_jobs_operation_id_unique": {
+ "name": "channel_jobs_operation_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["operation_id"]
+ },
+ "channel_jobs_scope_unique": {
+ "name": "channel_jobs_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_member_grants": {
+ "name": "channel_member_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_id": {
+ "name": "member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_owner_id": {
+ "name": "device_owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "working_directory": {
+ "name": "working_directory",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_by_member_id": {
+ "name": "requested_by_member_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "decided_at": {
+ "name": "decided_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoke_reason": {
+ "name": "revoke_reason",
+ "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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channel_member_grants_owner_status_idx": {
+ "name": "channel_member_grants_owner_status_idx",
+ "columns": [
+ {
+ "expression": "device_owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_member_grants_member_unique": {
+ "name": "channel_member_grants_member_unique",
+ "columns": [
+ {
+ "expression": "member_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_member_grants_channel_id_channels_id_fk": {
+ "name": "channel_member_grants_channel_id_channels_id_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_device_owner_id_users_id_fk": {
+ "name": "channel_member_grants_device_owner_id_users_id_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "users",
+ "columnsFrom": ["device_owner_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_member_fk": {
+ "name": "channel_member_grants_member_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "channel_member_grants_requester_fk": {
+ "name": "channel_member_grants_requester_fk",
+ "tableFrom": "channel_member_grants",
+ "tableTo": "channel_members",
+ "columnsFrom": ["channel_id", "requested_by_member_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_members": {
+ "name": "channel_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_read_sequence": {
+ "name": "last_read_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channel_members_channel_user_unique": {
+ "name": "channel_members_channel_user_unique",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"channel_members\".\"user_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_members_user_id_idx": {
+ "name": "channel_members_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_members_agent_id_idx": {
+ "name": "channel_members_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_members_channel_id_channels_id_fk": {
+ "name": "channel_members_channel_id_channels_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_members_user_id_users_id_fk": {
+ "name": "channel_members_user_id_users_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_members_agent_id_agents_id_fk": {
+ "name": "channel_members_agent_id_agents_id_fk",
+ "tableFrom": "channel_members",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_members_scope_unique": {
+ "name": "channel_members_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "channel_members_actor_type_check": {
+ "name": "channel_members_actor_type_check",
+ "value": "\"channel_members\".\"actor_type\" IN ('user', 'agent')"
+ },
+ "channel_members_user_shape_check": {
+ "name": "channel_members_user_shape_check",
+ "value": "\"channel_members\".\"actor_type\" <> 'user' OR \"channel_members\".\"role\" IS NOT NULL"
+ },
+ "channel_members_agent_shape_check": {
+ "name": "channel_members_agent_shape_check",
+ "value": "\"channel_members\".\"actor_type\" <> 'agent' OR (\"channel_members\".\"name\" IS NOT NULL AND \"channel_members\".\"config\" IS NOT NULL)"
+ },
+ "channel_members_user_id_owner_check": {
+ "name": "channel_members_user_id_owner_check",
+ "value": "\"channel_members\".\"user_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
+ },
+ "channel_members_role_owner_check": {
+ "name": "channel_members_role_owner_check",
+ "value": "\"channel_members\".\"role\" IS NULL OR \"channel_members\".\"actor_type\" = 'user'"
+ },
+ "channel_members_agent_id_owner_check": {
+ "name": "channel_members_agent_id_owner_check",
+ "value": "\"channel_members\".\"agent_id\" IS NULL OR \"channel_members\".\"actor_type\" = 'agent'"
+ },
+ "channel_members_config_owner_check": {
+ "name": "channel_members_config_owner_check",
+ "value": "\"channel_members\".\"config\" IS NULL OR \"channel_members\".\"actor_type\" <> 'user'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.channel_message_files": {
+ "name": "channel_message_files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "channel_message_files_file_idx": {
+ "name": "channel_message_files_file_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_message_files_message_id_channel_messages_id_fk": {
+ "name": "channel_message_files_message_id_channel_messages_id_fk",
+ "tableFrom": "channel_message_files",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_message_files_file_id_files_id_fk": {
+ "name": "channel_message_files_file_id_files_id_fk",
+ "tableFrom": "channel_message_files",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_message_files_message_file_unique": {
+ "name": "channel_message_files_message_file_unique",
+ "nullsNotDistinct": false,
+ "columns": ["message_id", "file_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_messages": {
+ "name": "channel_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mentions": {
+ "name": "mentions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "request_key": {
+ "name": "request_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_to_id": {
+ "name": "reply_to_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "routing_status": {
+ "name": "routing_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "routing_source": {
+ "name": "routing_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "routing_reason": {
+ "name": "routing_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "routing_attempt": {
+ "name": "routing_attempt",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "recipient_member_ids": {
+ "name": "recipient_member_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "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": "now()"
+ }
+ },
+ "indexes": {
+ "channel_messages_sequence_unique": {
+ "name": "channel_messages_sequence_unique",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_messages_request_key_unique": {
+ "name": "channel_messages_request_key_unique",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "request_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_messages_thread_sequence_idx": {
+ "name": "channel_messages_thread_sequence_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_messages_request_sequence_idx": {
+ "name": "channel_messages_request_sequence_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sequence",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channel_messages\".\"routing_status\" <> 'reply'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channel_messages_routing_pending_idx": {
+ "name": "channel_messages_routing_pending_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channel_messages\".\"routing_status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_messages_channel_id_channels_id_fk": {
+ "name": "channel_messages_channel_id_channels_id_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_messages_user_id_users_id_fk": {
+ "name": "channel_messages_user_id_users_id_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_messages_agent_id_agents_id_fk": {
+ "name": "channel_messages_agent_id_agents_id_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channel_messages_thread_fk": {
+ "name": "channel_messages_thread_fk",
+ "tableFrom": "channel_messages",
+ "tableTo": "channel_threads",
+ "columnsFrom": ["channel_id", "thread_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_messages_scope_unique": {
+ "name": "channel_messages_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "channel_messages_sender_check": {
+ "name": "channel_messages_sender_check",
+ "value": "\"channel_messages\".\"user_id\" IS NULL OR \"channel_messages\".\"agent_id\" IS NULL"
+ },
+ "channel_messages_user_sender_check": {
+ "name": "channel_messages_user_sender_check",
+ "value": "\"channel_messages\".\"routing_status\" <> 'reply' OR \"channel_messages\".\"user_id\" IS NULL"
+ },
+ "channel_messages_agent_sender_check": {
+ "name": "channel_messages_agent_sender_check",
+ "value": "\"channel_messages\".\"routing_status\" = 'reply' OR \"channel_messages\".\"agent_id\" IS NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.channel_threads": {
+ "name": "channel_threads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "root_message_id": {
+ "name": "root_message_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "root_sequence": {
+ "name": "root_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "follower_member_ids": {
+ "name": "follower_member_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "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": "now()"
+ }
+ },
+ "indexes": {
+ "channel_threads_root_unique": {
+ "name": "channel_threads_root_unique",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "root_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channel_threads_channel_id_channels_id_fk": {
+ "name": "channel_threads_channel_id_channels_id_fk",
+ "tableFrom": "channel_threads",
+ "tableTo": "channels",
+ "columnsFrom": ["channel_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_threads_root_fk": {
+ "name": "channel_threads_root_fk",
+ "tableFrom": "channel_threads",
+ "tableTo": "channel_messages",
+ "columnsFrom": ["channel_id", "root_message_id"],
+ "columnsTo": ["channel_id", "id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "channel_threads_scope_unique": {
+ "name": "channel_threads_scope_unique",
+ "nullsNotDistinct": false,
+ "columns": ["channel_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channels": {
+ "name": "channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence": {
+ "name": "sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "archived": {
+ "name": "archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channels_user_id_idx": {
+ "name": "channels_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channels_direct_unique": {
+ "name": "channels_direct_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "coalesce(\"workspace_id\", '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"channels\".\"agent_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channels_project_id_idx": {
+ "name": "channels_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channels\".\"project_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channels_workspace_visibility_idx": {
+ "name": "channels_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channels_user_id_users_id_fk": {
+ "name": "channels_user_id_users_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channels_workspace_id_workspaces_id_fk": {
+ "name": "channels_workspace_id_workspaces_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channels_project_id_projects_id_fk": {
+ "name": "channels_project_id_projects_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channels_agent_id_agents_id_fk": {
+ "name": "channels_agent_id_agents_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "channels_direct_visibility_check": {
+ "name": "channels_direct_visibility_check",
+ "value": "\"channels\".\"agent_id\" IS NULL OR \"channels\".\"visibility\" = 'private'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.chat_groups": {
+ "name": "chat_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_color": {
+ "name": "background_color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market_identifier": {
+ "name": "market_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned": {
+ "name": "pinned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_groups_client_id_user_id_unique": {
+ "name": "chat_groups_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_user_id_idx": {
+ "name": "chat_groups_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_group_id_idx": {
+ "name": "chat_groups_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_workspace_id_idx": {
+ "name": "chat_groups_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_workspace_visibility_idx": {
+ "name": "chat_groups_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_groups_user_id_users_id_fk": {
+ "name": "chat_groups_user_id_users_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_workspace_id_workspaces_id_fk": {
+ "name": "chat_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_group_id_session_groups_id_fk": {
+ "name": "chat_groups_group_id_session_groups_id_fk",
+ "tableFrom": "chat_groups",
+ "tableTo": "session_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.chat_groups_agents": {
+ "name": "chat_groups_agents",
+ "schema": "",
+ "columns": {
+ "chat_group_id": {
+ "name": "chat_group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "order": {
+ "name": "order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'participant'"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_groups_agents_user_id_idx": {
+ "name": "chat_groups_agents_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chat_groups_agents_workspace_id_idx": {
+ "name": "chat_groups_agents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_groups_agents_chat_group_id_chat_groups_id_fk": {
+ "name": "chat_groups_agents_chat_group_id_chat_groups_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["chat_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_agents_agent_id_agents_id_fk": {
+ "name": "chat_groups_agents_agent_id_agents_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_agents_user_id_users_id_fk": {
+ "name": "chat_groups_agents_user_id_users_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_groups_agents_workspace_id_workspaces_id_fk": {
+ "name": "chat_groups_agents_workspace_id_workspaces_id_fk",
+ "tableFrom": "chat_groups_agents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "chat_groups_agents_chat_group_id_agent_id_pk": {
+ "name": "chat_groups_agents_chat_group_id_agent_id_pk",
+ "columns": ["chat_group_id", "agent_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_connector_tools": {
+ "name": "user_connector_tools",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_connector_id": {
+ "name": "user_connector_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_name": {
+ "name": "tool_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_schema": {
+ "name": "input_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_schema": {
+ "name": "output_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crud_type": {
+ "name": "crud_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "render_config": {
+ "name": "render_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_work_artifact": {
+ "name": "is_work_artifact",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "work_artifact_config": {
+ "name": "work_artifact_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "limit_config": {
+ "name": "limit_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_connector_tools_connector_tool_unique": {
+ "name": "user_connector_tools_connector_tool_unique",
+ "columns": [
+ {
+ "expression": "user_connector_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connector_tools_user_id_idx": {
+ "name": "user_connector_tools_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connector_tools_connector_id_idx": {
+ "name": "user_connector_tools_connector_id_idx",
+ "columns": [
+ {
+ "expression": "user_connector_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connector_tools_workspace_id_idx": {
+ "name": "user_connector_tools_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_connector_tools_user_connector_id_user_connectors_id_fk": {
+ "name": "user_connector_tools_user_connector_id_user_connectors_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "user_connectors",
+ "columnsFrom": ["user_connector_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_connector_tools_user_id_users_id_fk": {
+ "name": "user_connector_tools_user_id_users_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_connector_tools_workspace_id_workspaces_id_fk": {
+ "name": "user_connector_tools_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_connector_tools",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_connectors": {
+ "name": "user_connectors",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mcp_server_url": {
+ "name": "mcp_server_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_connection_type": {
+ "name": "mcp_connection_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_stdio_config": {
+ "name": "mcp_stdio_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_enabled": {
+ "name": "is_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "oidc_config": {
+ "name": "oidc_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_connectors_personal_identifier_idx": {
+ "name": "user_connectors_personal_identifier_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"user_connectors\".\"workspace_id\" IS NULL AND \"user_connectors\".\"agent_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_workspace_identifier_idx": {
+ "name": "user_connectors_workspace_identifier_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"user_connectors\".\"workspace_id\" IS NOT NULL AND \"user_connectors\".\"agent_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_agent_identifier_idx": {
+ "name": "user_connectors_agent_identifier_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"user_connectors\".\"agent_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_user_id_idx": {
+ "name": "user_connectors_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_token_expires_at_idx": {
+ "name": "user_connectors_token_expires_at_idx",
+ "columns": [
+ {
+ "expression": "token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_workspace_id_idx": {
+ "name": "user_connectors_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_connectors_agent_id_idx": {
+ "name": "user_connectors_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_connectors_user_id_users_id_fk": {
+ "name": "user_connectors_user_id_users_id_fk",
+ "tableFrom": "user_connectors",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_connectors_workspace_id_workspaces_id_fk": {
+ "name": "user_connectors_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_connectors",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_connectors_agent_id_agents_id_fk": {
+ "name": "user_connectors_agent_id_agents_id_fk",
+ "tableFrom": "user_connectors",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_installed_plugins": {
+ "name": "user_installed_plugins",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_params": {
+ "name": "custom_params",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_installed_plugins_workspace_id_idx": {
+ "name": "user_installed_plugins_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_installed_plugins_user_id_users_id_fk": {
+ "name": "user_installed_plugins_user_id_users_id_fk",
+ "tableFrom": "user_installed_plugins",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_installed_plugins_workspace_id_workspaces_id_fk": {
+ "name": "user_installed_plugins_workspace_id_workspaces_id_fk",
+ "tableFrom": "user_installed_plugins",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_installed_plugins_user_id_identifier_pk": {
+ "name": "user_installed_plugins_user_id_identifier_pk",
+ "columns": ["user_id", "identifier"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.dashboard_items": {
+ "name": "dashboard_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "dashboard_id": {
+ "name": "dashboard_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "widget_id": {
+ "name": "widget_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "dashboard_items_dashboard_id_widget_id_unique": {
+ "name": "dashboard_items_dashboard_id_widget_id_unique",
+ "columns": [
+ {
+ "expression": "dashboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_dashboard_id_sort_order_idx": {
+ "name": "dashboard_items_dashboard_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "dashboard_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_widget_id_idx": {
+ "name": "dashboard_items_widget_id_idx",
+ "columns": [
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_user_id_idx": {
+ "name": "dashboard_items_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboard_items_workspace_id_idx": {
+ "name": "dashboard_items_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "dashboard_items_dashboard_id_dashboards_id_fk": {
+ "name": "dashboard_items_dashboard_id_dashboards_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "dashboards",
+ "columnsFrom": ["dashboard_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_widget_id_widgets_id_fk": {
+ "name": "dashboard_items_widget_id_widgets_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "widgets",
+ "columnsFrom": ["widget_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_user_id_users_id_fk": {
+ "name": "dashboard_items_user_id_users_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboard_items_workspace_id_workspaces_id_fk": {
+ "name": "dashboard_items_workspace_id_workspaces_id_fk",
+ "tableFrom": "dashboard_items",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.dashboards": {
+ "name": "dashboards",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "dashboards_personal_idx": {
+ "name": "dashboards_personal_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"dashboards\".\"workspace_id\" IS NULL AND \"dashboards\".\"project_id\" IS NULL AND \"dashboards\".\"agent_id\" IS NULL AND \"dashboards\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboards_workspace_idx": {
+ "name": "dashboards_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"dashboards\".\"workspace_id\" IS NOT NULL AND \"dashboards\".\"project_id\" IS NULL AND \"dashboards\".\"agent_id\" IS NULL AND \"dashboards\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboards_project_idx": {
+ "name": "dashboards_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"dashboards\".\"project_id\" IS NOT NULL AND \"dashboards\".\"agent_id\" IS NULL AND \"dashboards\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboards_agent_idx": {
+ "name": "dashboards_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"dashboards\".\"agent_id\" IS NOT NULL AND \"dashboards\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboards_user_id_idx": {
+ "name": "dashboards_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "dashboards_workspace_id_idx": {
+ "name": "dashboards_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "dashboards_user_id_users_id_fk": {
+ "name": "dashboards_user_id_users_id_fk",
+ "tableFrom": "dashboards",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboards_workspace_id_workspaces_id_fk": {
+ "name": "dashboards_workspace_id_workspaces_id_fk",
+ "tableFrom": "dashboards",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboards_project_id_projects_id_fk": {
+ "name": "dashboards_project_id_projects_id_fk",
+ "tableFrom": "dashboards",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "dashboards_agent_id_agents_id_fk": {
+ "name": "dashboards_agent_id_agents_id_fk",
+ "tableFrom": "dashboards",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.devices": {
+ "name": "devices",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "shared_from_device_id": {
+ "name": "shared_from_device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identity_source": {
+ "name": "identity_source",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hostname": {
+ "name": "hostname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "architecture": {
+ "name": "architecture",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "friendly_name": {
+ "name": "friendly_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default_cwd": {
+ "name": "default_cwd",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recent_cwds": {
+ "name": "recent_cwds",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "working_dirs": {
+ "name": "working_dirs",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'[]'::jsonb"
+ },
+ "first_seen_at": {
+ "name": "first_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "devices_user_id_device_id_unique": {
+ "name": "devices_user_id_device_id_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"devices\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "devices_workspace_id_device_id_unique": {
+ "name": "devices_workspace_id_device_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"devices\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "devices_user_id_idx": {
+ "name": "devices_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "devices_workspace_id_idx": {
+ "name": "devices_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "devices_workspace_visibility_idx": {
+ "name": "devices_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "devices_user_id_users_id_fk": {
+ "name": "devices_user_id_users_id_fk",
+ "tableFrom": "devices",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "devices_workspace_id_workspaces_id_fk": {
+ "name": "devices_workspace_id_workspaces_id_fk",
+ "tableFrom": "devices",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_comment_mentions": {
+ "name": "document_comment_mentions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "comment_id": {
+ "name": "comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentioned_user_id": {
+ "name": "mentioned_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_comment_mentions_comment_id_mentioned_user_id_unique": {
+ "name": "document_comment_mentions_comment_id_mentioned_user_id_unique",
+ "columns": [
+ {
+ "expression": "comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "mentioned_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comment_mentions_mentioned_user_id_created_at_idx": {
+ "name": "document_comment_mentions_mentioned_user_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "mentioned_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comment_mentions_workspace_id_idx": {
+ "name": "document_comment_mentions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_comment_mentions_comment_id_document_comments_id_fk": {
+ "name": "document_comment_mentions_comment_id_document_comments_id_fk",
+ "tableFrom": "document_comment_mentions",
+ "tableTo": "document_comments",
+ "columnsFrom": ["comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_mentions_mentioned_user_id_users_id_fk": {
+ "name": "document_comment_mentions_mentioned_user_id_users_id_fk",
+ "tableFrom": "document_comment_mentions",
+ "tableTo": "users",
+ "columnsFrom": ["mentioned_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_mentions_workspace_id_workspaces_id_fk": {
+ "name": "document_comment_mentions_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_comment_mentions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_comments": {
+ "name": "document_comments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_comment_id": {
+ "name": "parent_comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reply_to_comment_id": {
+ "name": "reply_to_comment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selection_anchor": {
+ "name": "selection_anchor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_comments_document_id_author_user_id_client_id_unique": {
+ "name": "document_comments_document_id_author_user_id_client_id_unique",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comments_parent_comment_id_created_at_id_idx": {
+ "name": "document_comments_parent_comment_id_created_at_id_idx",
+ "columns": [
+ {
+ "expression": "parent_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comments_reply_to_comment_id_idx": {
+ "name": "document_comments_reply_to_comment_id_idx",
+ "columns": [
+ {
+ "expression": "reply_to_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comments_document_id_created_at_id_idx": {
+ "name": "document_comments_document_id_created_at_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comments_author_user_id_idx": {
+ "name": "document_comments_author_user_id_idx",
+ "columns": [
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_comments_workspace_id_idx": {
+ "name": "document_comments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_comments_document_id_documents_id_fk": {
+ "name": "document_comments_document_id_documents_id_fk",
+ "tableFrom": "document_comments",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comments_parent_comment_id_document_comments_id_fk": {
+ "name": "document_comments_parent_comment_id_document_comments_id_fk",
+ "tableFrom": "document_comments",
+ "tableTo": "document_comments",
+ "columnsFrom": ["parent_comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "document_comments_reply_to_comment_id_document_comments_id_fk": {
+ "name": "document_comments_reply_to_comment_id_document_comments_id_fk",
+ "tableFrom": "document_comments",
+ "tableTo": "document_comments",
+ "columnsFrom": ["reply_to_comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "document_comments_author_user_id_users_id_fk": {
+ "name": "document_comments_author_user_id_users_id_fk",
+ "tableFrom": "document_comments",
+ "tableTo": "users",
+ "columnsFrom": ["author_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "document_comments_workspace_id_workspaces_id_fk": {
+ "name": "document_comments_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_comments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "document_comments_reply_has_no_anchor": {
+ "name": "document_comments_reply_has_no_anchor",
+ "value": "\"document_comments\".\"parent_comment_id\" IS NULL OR \"document_comments\".\"selection_anchor\" IS NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.document_histories": {
+ "name": "document_histories",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "save_source": {
+ "name": "save_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "saved_at": {
+ "name": "saved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "document_histories_document_id_idx": {
+ "name": "document_histories_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_histories_user_id_idx": {
+ "name": "document_histories_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_histories_workspace_id_idx": {
+ "name": "document_histories_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_histories_saved_at_idx": {
+ "name": "document_histories_saved_at_idx",
+ "columns": [
+ {
+ "expression": "saved_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_histories_document_id_documents_id_fk": {
+ "name": "document_histories_document_id_documents_id_fk",
+ "tableFrom": "document_histories",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_histories_user_id_users_id_fk": {
+ "name": "document_histories_user_id_users_id_fk",
+ "tableFrom": "document_histories",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_histories_workspace_id_workspaces_id_fk": {
+ "name": "document_histories_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_histories",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_likes": {
+ "name": "document_likes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_likes_document_id_user_id_unique": {
+ "name": "document_likes_document_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_likes_document_id_created_at_idx": {
+ "name": "document_likes_document_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_likes_user_id_idx": {
+ "name": "document_likes_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_likes_workspace_id_idx": {
+ "name": "document_likes_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_likes_document_id_documents_id_fk": {
+ "name": "document_likes_document_id_documents_id_fk",
+ "tableFrom": "document_likes",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_likes_user_id_users_id_fk": {
+ "name": "document_likes_user_id_users_id_fk",
+ "tableFrom": "document_likes",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_likes_workspace_id_workspaces_id_fk": {
+ "name": "document_likes_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_likes",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_shares": {
+ "name": "document_shares",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'read'"
+ },
+ "page_view_count": {
+ "name": "page_view_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_shares_document_id_unique": {
+ "name": "document_shares_document_id_unique",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_shares_user_id_idx": {
+ "name": "document_shares_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_shares_workspace_id_idx": {
+ "name": "document_shares_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_shares_document_id_documents_id_fk": {
+ "name": "document_shares_document_id_documents_id_fk",
+ "tableFrom": "document_shares",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_shares_user_id_users_id_fk": {
+ "name": "document_shares_user_id_users_id_fk",
+ "tableFrom": "document_shares",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_shares_workspace_id_workspaces_id_fk": {
+ "name": "document_shares_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_shares",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.environments": {
+ "name": "environments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "configuration": {
+ "name": "configuration",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "environments_user_id_idx": {
+ "name": "environments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environments_workspace_id_idx": {
+ "name": "environments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environments_workspace_visibility_idx": {
+ "name": "environments_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environments_user_name_unique": {
+ "name": "environments_user_name_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"environments\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environments_workspace_user_name_unique": {
+ "name": "environments_workspace_user_name_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"environments\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "environments_user_id_users_id_fk": {
+ "name": "environments_user_id_users_id_fk",
+ "tableFrom": "environments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "environments_workspace_id_workspaces_id_fk": {
+ "name": "environments_workspace_id_workspaces_id_fk",
+ "tableFrom": "environments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "environments_name_not_empty": {
+ "name": "environments_name_not_empty",
+ "value": "length(btrim(\"environments\".\"name\")) > 0"
+ },
+ "environments_configuration_object": {
+ "name": "environments_configuration_object",
+ "value": "jsonb_typeof(\"environments\".\"configuration\") = 'object'"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.environment_instances": {
+ "name": "environment_instances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "environment_id": {
+ "name": "environment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_scope": {
+ "name": "provider_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_resource_id": {
+ "name": "provider_resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "working_directory": {
+ "name": "working_directory",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "configuration_snapshot": {
+ "name": "configuration_snapshot",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "configuration": {
+ "name": "configuration",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "build_id": {
+ "name": "build_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "build_error": {
+ "name": "build_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "environment_instances_environment_id_id_unique": {
+ "name": "environment_instances_environment_id_id_unique",
+ "columns": [
+ {
+ "expression": "environment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environment_instances_device_path_unique": {
+ "name": "environment_instances_device_path_unique",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "working_directory",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"environment_instances\".\"device_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environment_instances_provider_path_unique": {
+ "name": "environment_instances_provider_path_unique",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_scope",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "working_directory",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"environment_instances\".\"device_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "environment_instances_environment_id_idx": {
+ "name": "environment_instances_environment_id_idx",
+ "columns": [
+ {
+ "expression": "environment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "environment_instances_environment_id_environments_id_fk": {
+ "name": "environment_instances_environment_id_environments_id_fk",
+ "tableFrom": "environment_instances",
+ "tableTo": "environments",
+ "columnsFrom": ["environment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "environment_instances_device_id_devices_id_fk": {
+ "name": "environment_instances_device_id_devices_id_fk",
+ "tableFrom": "environment_instances",
+ "tableTo": "devices",
+ "columnsFrom": ["device_id"],
+ "columnsTo": ["id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "environment_instances_name_not_empty": {
+ "name": "environment_instances_name_not_empty",
+ "value": "length(btrim(\"environment_instances\".\"name\")) > 0"
+ },
+ "environment_instances_directory_not_empty": {
+ "name": "environment_instances_directory_not_empty",
+ "value": "length(btrim(\"environment_instances\".\"working_directory\")) > 0"
+ },
+ "environment_instances_snapshot_object": {
+ "name": "environment_instances_snapshot_object",
+ "value": "jsonb_typeof(\"environment_instances\".\"configuration_snapshot\") = 'object'"
+ },
+ "environment_instances_configuration_object": {
+ "name": "environment_instances_configuration_object",
+ "value": "\"environment_instances\".\"configuration\" IS NULL OR jsonb_typeof(\"environment_instances\".\"configuration\") = 'object'"
+ },
+ "environment_instances_binding": {
+ "name": "environment_instances_binding",
+ "value": "(\n \"environment_instances\".\"kind\" = 'device' AND \"environment_instances\".\"device_id\" IS NOT NULL AND \"environment_instances\".\"provider\" IS NULL AND \"environment_instances\".\"provider_scope\" IS NULL AND \"environment_instances\".\"provider_resource_id\" IS NULL\n ) OR (\n \"environment_instances\".\"kind\" <> 'device' AND \"environment_instances\".\"device_id\" IS NULL AND\n \"environment_instances\".\"provider\" IS NOT NULL AND length(btrim(\"environment_instances\".\"provider\")) > 0 AND\n \"environment_instances\".\"provider_scope\" IS NOT NULL AND length(btrim(\"environment_instances\".\"provider_scope\")) > 0 AND\n \"environment_instances\".\"provider_resource_id\" IS NOT NULL AND length(btrim(\"environment_instances\".\"provider_resource_id\")) > 0\n )"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.expertise_bindings": {
+ "name": "expertise_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bound_workspace_id": {
+ "name": "bound_workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "bound_user_id": {
+ "name": "bound_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contribution_mode": {
+ "name": "contribution_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'derive'"
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_bindings_agent_domain_unique": {
+ "name": "expertise_bindings_agent_domain_unique",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_bindings\".\"agent_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_bindings_project_domain_unique": {
+ "name": "expertise_bindings_project_domain_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_bindings\".\"project_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_bindings_workspace_domain_unique": {
+ "name": "expertise_bindings_workspace_domain_unique",
+ "columns": [
+ {
+ "expression": "bound_workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_bindings\".\"bound_workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_bindings_user_domain_unique": {
+ "name": "expertise_bindings_user_domain_unique",
+ "columns": [
+ {
+ "expression": "bound_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_bindings\".\"bound_user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_bindings_domain_idx": {
+ "name": "expertise_bindings_domain_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_bindings_workspace_id_idx": {
+ "name": "expertise_bindings_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_bindings_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_bindings_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_agent_id_agents_id_fk": {
+ "name": "expertise_bindings_agent_id_agents_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_project_id_projects_id_fk": {
+ "name": "expertise_bindings_project_id_projects_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_bound_workspace_id_workspaces_id_fk": {
+ "name": "expertise_bindings_bound_workspace_id_workspaces_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["bound_workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_bound_user_id_users_id_fk": {
+ "name": "expertise_bindings_bound_user_id_users_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "users",
+ "columnsFrom": ["bound_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_added_by_user_id_users_id_fk": {
+ "name": "expertise_bindings_added_by_user_id_users_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_bindings_workspace_id_workspaces_id_fk": {
+ "name": "expertise_bindings_workspace_id_workspaces_id_fk",
+ "tableFrom": "expertise_bindings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "expertise_bindings_exactly_one_carrier": {
+ "name": "expertise_bindings_exactly_one_carrier",
+ "value": "(\"expertise_bindings\".\"agent_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"project_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_workspace_id\" IS NOT NULL)::int + (\"expertise_bindings\".\"bound_user_id\" IS NOT NULL)::int = 1"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.expertise_domain_snapshots": {
+ "name": "expertise_domain_snapshots",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "run_index": {
+ "name": "run_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "learned_total": {
+ "name": "learned_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "retired_total": {
+ "name": "retired_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "active_count": {
+ "name": "active_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "compiled_count": {
+ "name": "compiled_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "layer_counts": {
+ "name": "layer_counts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "p_inf": {
+ "name": "p_inf",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tau": {
+ "name": "tau",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "maturity": {
+ "name": "maturity",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fit_sample_size": {
+ "name": "fit_sample_size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fit_r2": {
+ "name": "fit_r2",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fit_confidence": {
+ "name": "fit_confidence",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "fit_computed_at": {
+ "name": "fit_computed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tau_pinned": {
+ "name": "tau_pinned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "observed_span": {
+ "name": "observed_span",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plateau_kind": {
+ "name": "plateau_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layer_coverage": {
+ "name": "layer_coverage",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canon_coverage": {
+ "name": "canon_coverage",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_rate": {
+ "name": "active_rate",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_domain_snapshots_domain_run_index_unique": {
+ "name": "expertise_domain_snapshots_domain_run_index_unique",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "run_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domain_snapshots_domain_captured_idx": {
+ "name": "expertise_domain_snapshots_domain_captured_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "captured_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domain_snapshots_pending_fit_idx": {
+ "name": "expertise_domain_snapshots_pending_fit_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"expertise_domain_snapshots\".\"fit_computed_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_domain_snapshots_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_domain_snapshots_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_domain_snapshots",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_domain_snapshots_run_id_expertise_runs_id_fk": {
+ "name": "expertise_domain_snapshots_run_id_expertise_runs_id_fk",
+ "tableFrom": "expertise_domain_snapshots",
+ "tableTo": "expertise_runs",
+ "columnsFrom": ["run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_domain_snapshots_run_domain_fk": {
+ "name": "expertise_domain_snapshots_run_domain_fk",
+ "tableFrom": "expertise_domain_snapshots",
+ "tableTo": "expertise_runs",
+ "columnsFrom": ["run_id", "domain_id"],
+ "columnsTo": ["id", "domain_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_domains": {
+ "name": "expertise_domains",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'user'"
+ },
+ "parent_domain_id": {
+ "name": "parent_domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domain_filter": {
+ "name": "domain_filter",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "out_of_scope": {
+ "name": "out_of_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layers": {
+ "name": "layers",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "layer_source": {
+ "name": "layer_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invented'"
+ },
+ "canon_entries": {
+ "name": "canon_entries",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "canon_document_id": {
+ "name": "canon_document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flow": {
+ "name": "flow",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "evidence_spec": {
+ "name": "evidence_spec",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "lesson_base_document_id": {
+ "name": "lesson_base_document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "anchor_candidates": {
+ "name": "anchor_candidates",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "anchor_chosen_at": {
+ "name": "anchor_chosen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "anchor_chosen_by_user_id": {
+ "name": "anchor_chosen_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seed_state": {
+ "name": "seed_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'seeding'"
+ },
+ "seed_run_id": {
+ "name": "seed_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_domains_slug_user_unique": {
+ "name": "expertise_domains_slug_user_unique",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_domains\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domains_slug_workspace_unique": {
+ "name": "expertise_domains_slug_workspace_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_domains\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domains_user_id_idx": {
+ "name": "expertise_domains_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domains_workspace_visibility_idx": {
+ "name": "expertise_domains_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_domains_parent_idx": {
+ "name": "expertise_domains_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_domains_user_id_users_id_fk": {
+ "name": "expertise_domains_user_id_users_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_domains_workspace_id_workspaces_id_fk": {
+ "name": "expertise_domains_workspace_id_workspaces_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_domains_parent_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_domains_parent_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["parent_domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_domains_canon_document_id_documents_id_fk": {
+ "name": "expertise_domains_canon_document_id_documents_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "documents",
+ "columnsFrom": ["canon_document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_domains_lesson_base_document_id_documents_id_fk": {
+ "name": "expertise_domains_lesson_base_document_id_documents_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "documents",
+ "columnsFrom": ["lesson_base_document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_domains_anchor_chosen_by_user_id_users_id_fk": {
+ "name": "expertise_domains_anchor_chosen_by_user_id_users_id_fk",
+ "tableFrom": "expertise_domains",
+ "tableTo": "users",
+ "columnsFrom": ["anchor_chosen_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_hits": {
+ "name": "expertise_hits",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "lesson_id": {
+ "name": "lesson_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "where": {
+ "name": "where",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "example": {
+ "name": "example",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "severity": {
+ "name": "severity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence_id": {
+ "name": "evidence_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_check_result_id": {
+ "name": "source_check_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_message_id": {
+ "name": "source_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_decision": {
+ "name": "user_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_decision_at": {
+ "name": "user_decision_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": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_hits_lesson_created_idx": {
+ "name": "expertise_hits_lesson_created_idx",
+ "columns": [
+ {
+ "expression": "lesson_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_hits_run_idx": {
+ "name": "expertise_hits_run_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_hits_domain_outcome_idx": {
+ "name": "expertise_hits_domain_outcome_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "outcome",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_hits_operation_idx": {
+ "name": "expertise_hits_operation_idx",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_hits_source_message_idx": {
+ "name": "expertise_hits_source_message_idx",
+ "columns": [
+ {
+ "expression": "source_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"expertise_hits\".\"source_message_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_hits_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_hits_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_evidence_id_verify_evidence_id_fk": {
+ "name": "expertise_hits_evidence_id_verify_evidence_id_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "verify_evidence",
+ "columnsFrom": ["evidence_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_operation_id_agent_operations_id_fk": {
+ "name": "expertise_hits_operation_id_agent_operations_id_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_source_check_result_id_verify_check_results_id_fk": {
+ "name": "expertise_hits_source_check_result_id_verify_check_results_id_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "verify_check_results",
+ "columnsFrom": ["source_check_result_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_source_message_id_messages_id_fk": {
+ "name": "expertise_hits_source_message_id_messages_id_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "messages",
+ "columnsFrom": ["source_message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_run_domain_fk": {
+ "name": "expertise_hits_run_domain_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "expertise_runs",
+ "columnsFrom": ["run_id", "domain_id"],
+ "columnsTo": ["id", "domain_id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_hits_lesson_domain_fk": {
+ "name": "expertise_hits_lesson_domain_fk",
+ "tableFrom": "expertise_hits",
+ "tableTo": "expertise_lessons",
+ "columnsFrom": ["lesson_id", "domain_id"],
+ "columnsTo": ["id", "domain_id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_insights": {
+ "name": "expertise_insights",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "headline": {
+ "name": "headline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_label": {
+ "name": "action_label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_target": {
+ "name": "action_target",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "dismiss_reason": {
+ "name": "dismiss_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stale_after_run_index": {
+ "name": "stale_after_run_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generated_by_operation_id": {
+ "name": "generated_by_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_insights_domain_status_idx": {
+ "name": "expertise_insights_domain_status_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_insights_user_status_idx": {
+ "name": "expertise_insights_user_status_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_insights_workspace_idx": {
+ "name": "expertise_insights_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_insights_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_insights_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_insights",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_insights_user_id_users_id_fk": {
+ "name": "expertise_insights_user_id_users_id_fk",
+ "tableFrom": "expertise_insights",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_insights_workspace_id_workspaces_id_fk": {
+ "name": "expertise_insights_workspace_id_workspaces_id_fk",
+ "tableFrom": "expertise_insights",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_insights_generated_by_operation_id_agent_operations_id_fk": {
+ "name": "expertise_insights_generated_by_operation_id_agent_operations_id_fk",
+ "tableFrom": "expertise_insights",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["generated_by_operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_lesson_revisions": {
+ "name": "expertise_lesson_revisions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "lesson_id": {
+ "name": "lesson_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sections": {
+ "name": "sections",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feedback": {
+ "name": "feedback",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "changed_by": {
+ "name": "changed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'user-feedback'"
+ },
+ "prev_title": {
+ "name": "prev_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "evidence": {
+ "name": "evidence",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "changed_by_user_id": {
+ "name": "changed_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_run_id": {
+ "name": "source_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_lesson_revisions_lesson_revision_unique": {
+ "name": "expertise_lesson_revisions_lesson_revision_unique",
+ "columns": [
+ {
+ "expression": "lesson_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "revision",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_lesson_revisions_lesson_idx": {
+ "name": "expertise_lesson_revisions_lesson_idx",
+ "columns": [
+ {
+ "expression": "lesson_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk": {
+ "name": "expertise_lesson_revisions_lesson_id_expertise_lessons_id_fk",
+ "tableFrom": "expertise_lesson_revisions",
+ "tableTo": "expertise_lessons",
+ "columnsFrom": ["lesson_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_lesson_revisions_changed_by_user_id_users_id_fk": {
+ "name": "expertise_lesson_revisions_changed_by_user_id_users_id_fk",
+ "tableFrom": "expertise_lesson_revisions",
+ "tableTo": "users",
+ "columnsFrom": ["changed_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_lesson_revisions_operation_id_agent_operations_id_fk": {
+ "name": "expertise_lesson_revisions_operation_id_agent_operations_id_fk",
+ "tableFrom": "expertise_lesson_revisions",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_lessons": {
+ "name": "expertise_lessons",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "code": {
+ "name": "code",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "polarity": {
+ "name": "polarity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sections": {
+ "name": "sections",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "layer": {
+ "name": "layer",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reason_kind": {
+ "name": "reason_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reason_source": {
+ "name": "reason_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canon_anchor": {
+ "name": "canon_anchor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "origin_run_id": {
+ "name": "origin_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "origin_hit_id": {
+ "name": "origin_hit_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "rejected_reason": {
+ "name": "rejected_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "salvaged_from_id": {
+ "name": "salvaged_from_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "retired_at": {
+ "name": "retired_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enforcement": {
+ "name": "enforcement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "direction": {
+ "name": "direction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "compilability": {
+ "name": "compilability",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'compilable'"
+ },
+ "backtest": {
+ "name": "backtest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "compiled_criterion_id": {
+ "name": "compiled_criterion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hit_count": {
+ "name": "hit_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "hit_run_count": {
+ "name": "hit_run_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "false_positive_count": {
+ "name": "false_positive_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_hit_at": {
+ "name": "last_hit_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_hit_run_id": {
+ "name": "last_hit_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generalized_from_ids": {
+ "name": "generalized_from_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "specificity": {
+ "name": "specificity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "example_count": {
+ "name": "example_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "current_revision": {
+ "name": "current_revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_lessons_domain_code_unique": {
+ "name": "expertise_lessons_domain_code_unique",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_lessons_domain_status_hits_idx": {
+ "name": "expertise_lessons_domain_status_hits_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "hit_count",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_lessons_domain_layer_idx": {
+ "name": "expertise_lessons_domain_layer_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "layer",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_lessons_compiled_criterion_idx": {
+ "name": "expertise_lessons_compiled_criterion_idx",
+ "columns": [
+ {
+ "expression": "compiled_criterion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_lessons_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_lessons_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_lessons",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_lessons_created_by_user_id_users_id_fk": {
+ "name": "expertise_lessons_created_by_user_id_users_id_fk",
+ "tableFrom": "expertise_lessons",
+ "tableTo": "users",
+ "columnsFrom": ["created_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk": {
+ "name": "expertise_lessons_salvaged_from_id_expertise_lessons_id_fk",
+ "tableFrom": "expertise_lessons",
+ "tableTo": "expertise_lessons",
+ "columnsFrom": ["salvaged_from_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk": {
+ "name": "expertise_lessons_compiled_criterion_id_verify_criteria_id_fk",
+ "tableFrom": "expertise_lessons",
+ "tableTo": "verify_criteria",
+ "columnsFrom": ["compiled_criterion_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "expertise_lessons_id_domain_unique": {
+ "name": "expertise_lessons_id_domain_unique",
+ "nullsNotDistinct": false,
+ "columns": ["id", "domain_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.expertise_runs": {
+ "name": "expertise_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "domain_id": {
+ "name": "domain_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "run_index": {
+ "name": "run_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_seed_run": {
+ "name": "is_seed_run",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject_id": {
+ "name": "subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "window_start": {
+ "name": "window_start",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "window_end": {
+ "name": "window_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reflection_key": {
+ "name": "reflection_key",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "had_human_in_loop": {
+ "name": "had_human_in_loop",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instance_count": {
+ "name": "instance_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "refine_count": {
+ "name": "refine_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "new_count": {
+ "name": "new_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "expertise_runs_domain_run_index_unique": {
+ "name": "expertise_runs_domain_run_index_unique",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "run_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_runs_domain_reflection_key_unique": {
+ "name": "expertise_runs_domain_reflection_key_unique",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "reflection_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"expertise_runs\".\"reflection_key\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_runs_domain_started_idx": {
+ "name": "expertise_runs_domain_started_idx",
+ "columns": [
+ {
+ "expression": "domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_runs_actor_idx": {
+ "name": "expertise_runs_actor_idx",
+ "columns": [
+ {
+ "expression": "actor_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "actor_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "expertise_runs_subject_idx": {
+ "name": "expertise_runs_subject_idx",
+ "columns": [
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "expertise_runs_domain_id_expertise_domains_id_fk": {
+ "name": "expertise_runs_domain_id_expertise_domains_id_fk",
+ "tableFrom": "expertise_runs",
+ "tableTo": "expertise_domains",
+ "columnsFrom": ["domain_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "expertise_runs_user_id_users_id_fk": {
+ "name": "expertise_runs_user_id_users_id_fk",
+ "tableFrom": "expertise_runs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "expertise_runs_workspace_id_workspaces_id_fk": {
+ "name": "expertise_runs_workspace_id_workspaces_id_fk",
+ "tableFrom": "expertise_runs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "expertise_runs_id_domain_unique": {
+ "name": "expertise_runs_id_domain_unique",
+ "nullsNotDistinct": false,
+ "columns": ["id", "domain_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.documents": {
+ "name": "documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_char_count": {
+ "name": "total_char_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "total_line_count": {
+ "name": "total_line_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pages": {
+ "name": "pages",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "documents_source_idx": {
+ "name": "documents_source_idx",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_file_type_idx": {
+ "name": "documents_file_type_idx",
+ "columns": [
+ {
+ "expression": "file_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_source_type_idx": {
+ "name": "documents_source_type_idx",
+ "columns": [
+ {
+ "expression": "source_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_user_id_idx": {
+ "name": "documents_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_file_id_idx": {
+ "name": "documents_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_parent_id_idx": {
+ "name": "documents_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_knowledge_base_id_idx": {
+ "name": "documents_knowledge_base_id_idx",
+ "columns": [
+ {
+ "expression": "knowledge_base_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_client_id_user_id_unique": {
+ "name": "documents_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_slug_user_id_unique": {
+ "name": "documents_slug_user_id_unique",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"documents\".\"workspace_id\" IS NULL AND \"documents\".\"slug\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_workspace_id_idx": {
+ "name": "documents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_workspace_visibility_idx": {
+ "name": "documents_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "documents_slug_workspace_id_unique": {
+ "name": "documents_slug_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"documents\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "documents_file_id_files_id_fk": {
+ "name": "documents_file_id_files_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "documents_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "documents_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "documents_parent_id_documents_id_fk": {
+ "name": "documents_parent_id_documents_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "documents",
+ "columnsFrom": ["parent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "documents_user_id_users_id_fk": {
+ "name": "documents_user_id_users_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "documents_workspace_id_workspaces_id_fk": {
+ "name": "documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "documents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.file_uploads": {
+ "name": "file_uploads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pathname": {
+ "name": "pathname",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "multipart_upload_id": {
+ "name": "multipart_upload_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "multipart_part_size": {
+ "name": "multipart_part_size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "file_uploads_user_scope_status_idx": {
+ "name": "file_uploads_user_scope_status_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_uploads_workspace_status_idx": {
+ "name": "file_uploads_workspace_status_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_uploads_status_expires_at_idx": {
+ "name": "file_uploads_status_expires_at_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_uploads_status_updated_at_id_idx": {
+ "name": "file_uploads_status_updated_at_id_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_uploads_live_pathname_unique": {
+ "name": "file_uploads_live_pathname_unique",
+ "columns": [
+ {
+ "expression": "pathname",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"file_uploads\".\"status\" IN ('active', 'cleaning')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "file_uploads_user_id_users_id_fk": {
+ "name": "file_uploads_user_id_users_id_fk",
+ "tableFrom": "file_uploads",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "file_uploads_workspace_id_workspaces_id_fk": {
+ "name": "file_uploads_workspace_id_workspaces_id_fk",
+ "tableFrom": "file_uploads",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "file_uploads_file_id_files_id_fk": {
+ "name": "file_uploads_file_id_files_id_fk",
+ "tableFrom": "file_uploads",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files": {
+ "name": "files",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_hash": {
+ "name": "file_hash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_task_id": {
+ "name": "chunk_task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "embedding_task_id": {
+ "name": "embedding_task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "file_hash_idx": {
+ "name": "file_hash_idx",
+ "columns": [
+ {
+ "expression": "file_hash",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_user_id_idx": {
+ "name": "files_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_parent_id_idx": {
+ "name": "files_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_chunk_task_id_idx": {
+ "name": "files_chunk_task_id_idx",
+ "columns": [
+ {
+ "expression": "chunk_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_embedding_task_id_idx": {
+ "name": "files_embedding_task_id_idx",
+ "columns": [
+ {
+ "expression": "embedding_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_client_id_user_id_unique": {
+ "name": "files_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_workspace_id_idx": {
+ "name": "files_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_workspace_visibility_idx": {
+ "name": "files_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "files_user_id_users_id_fk": {
+ "name": "files_user_id_users_id_fk",
+ "tableFrom": "files",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_file_hash_global_files_hash_id_fk": {
+ "name": "files_file_hash_global_files_hash_id_fk",
+ "tableFrom": "files",
+ "tableTo": "global_files",
+ "columnsFrom": ["file_hash"],
+ "columnsTo": ["hash_id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "files_parent_id_documents_id_fk": {
+ "name": "files_parent_id_documents_id_fk",
+ "tableFrom": "files",
+ "tableTo": "documents",
+ "columnsFrom": ["parent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "files_chunk_task_id_async_tasks_id_fk": {
+ "name": "files_chunk_task_id_async_tasks_id_fk",
+ "tableFrom": "files",
+ "tableTo": "async_tasks",
+ "columnsFrom": ["chunk_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "files_embedding_task_id_async_tasks_id_fk": {
+ "name": "files_embedding_task_id_async_tasks_id_fk",
+ "tableFrom": "files",
+ "tableTo": "async_tasks",
+ "columnsFrom": ["embedding_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "files_workspace_id_workspaces_id_fk": {
+ "name": "files_workspace_id_workspaces_id_fk",
+ "tableFrom": "files",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.global_files": {
+ "name": "global_files",
+ "schema": "",
+ "columns": {
+ "hash_id": {
+ "name": "hash_id",
+ "type": "varchar(64)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "file_type": {
+ "name": "file_type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size": {
+ "name": "size",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "creator": {
+ "name": "creator",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "global_files_creator_idx": {
+ "name": "global_files_creator_idx",
+ "columns": [
+ {
+ "expression": "creator",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "global_files_creator_users_id_fk": {
+ "name": "global_files_creator_users_id_fk",
+ "tableFrom": "global_files",
+ "tableTo": "users",
+ "columnsFrom": ["creator"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.knowledge_base_files": {
+ "name": "knowledge_base_files",
+ "schema": "",
+ "columns": {
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "knowledge_base_files_kb_id_idx": {
+ "name": "knowledge_base_files_kb_id_idx",
+ "columns": [
+ {
+ "expression": "knowledge_base_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_base_files_user_id_idx": {
+ "name": "knowledge_base_files_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_base_files_file_id_idx": {
+ "name": "knowledge_base_files_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_base_files_workspace_id_idx": {
+ "name": "knowledge_base_files_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "knowledge_base_files_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "knowledge_base_files",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "knowledge_base_files_file_id_files_id_fk": {
+ "name": "knowledge_base_files_file_id_files_id_fk",
+ "tableFrom": "knowledge_base_files",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "knowledge_base_files_user_id_users_id_fk": {
+ "name": "knowledge_base_files_user_id_users_id_fk",
+ "tableFrom": "knowledge_base_files",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "knowledge_base_files_workspace_id_workspaces_id_fk": {
+ "name": "knowledge_base_files_workspace_id_workspaces_id_fk",
+ "tableFrom": "knowledge_base_files",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "knowledge_base_files_knowledge_base_id_file_id_pk": {
+ "name": "knowledge_base_files_knowledge_base_id_file_id_pk",
+ "columns": ["knowledge_base_id", "file_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.knowledge_bases": {
+ "name": "knowledge_bases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_public": {
+ "name": "is_public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "knowledge_bases_client_id_user_id_unique": {
+ "name": "knowledge_bases_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_bases_user_id_idx": {
+ "name": "knowledge_bases_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_bases_workspace_id_idx": {
+ "name": "knowledge_bases_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "knowledge_bases_workspace_visibility_idx": {
+ "name": "knowledge_bases_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "knowledge_bases_user_id_users_id_fk": {
+ "name": "knowledge_bases_user_id_users_id_fk",
+ "tableFrom": "knowledge_bases",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "knowledge_bases_workspace_id_workspaces_id_fk": {
+ "name": "knowledge_bases_workspace_id_workspaces_id_fk",
+ "tableFrom": "knowledge_bases",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.fts_search_sync_capture_version": {
+ "name": "fts_search_sync_capture_version",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.fts_search_sync_outbox": {
+ "name": "fts_search_sync_outbox",
+ "schema": "",
+ "columns": {
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "available_at": {
+ "name": "available_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "dead_at": {
+ "name": "dead_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity": {
+ "name": "entity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locked_until": {
+ "name": "locked_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "smallint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 10
+ },
+ "revision": {
+ "name": "revision",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "nextval('fts_search_sync_revision_seq')"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "fts_search_sync_outbox_entity_document_id_unique": {
+ "name": "fts_search_sync_outbox_entity_document_id_unique",
+ "columns": [
+ {
+ "expression": "entity",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "fts_search_sync_outbox_claim_idx": {
+ "name": "fts_search_sync_outbox_claim_idx",
+ "columns": [
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "available_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "revision",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "fts_search_sync_outbox_dead_idx": {
+ "name": "fts_search_sync_outbox_dead_idx",
+ "columns": [
+ {
+ "expression": "dead_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "fts_search_sync_outbox_lease_idx": {
+ "name": "fts_search_sync_outbox_lease_idx",
+ "columns": [
+ {
+ "expression": "locked_until",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"fts_search_sync_outbox\".\"dead_at\" IS NULL AND \"fts_search_sync_outbox\".\"locked_until\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.generation_batches": {
+ "name": "generation_batches",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_topic_id": {
+ "name": "generation_topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "width": {
+ "name": "width",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "height": {
+ "name": "height",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ratio": {
+ "name": "ratio",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "generation_batches_user_id_idx": {
+ "name": "generation_batches_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generation_batches_topic_id_idx": {
+ "name": "generation_batches_topic_id_idx",
+ "columns": [
+ {
+ "expression": "generation_topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generation_batches_workspace_id_idx": {
+ "name": "generation_batches_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "generation_batches_user_id_users_id_fk": {
+ "name": "generation_batches_user_id_users_id_fk",
+ "tableFrom": "generation_batches",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generation_batches_workspace_id_workspaces_id_fk": {
+ "name": "generation_batches_workspace_id_workspaces_id_fk",
+ "tableFrom": "generation_batches",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generation_batches_generation_topic_id_generation_topics_id_fk": {
+ "name": "generation_batches_generation_topic_id_generation_topics_id_fk",
+ "tableFrom": "generation_batches",
+ "tableTo": "generation_topics",
+ "columnsFrom": ["generation_topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.generation_topics": {
+ "name": "generation_topics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cover_url": {
+ "name": "cover_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'image'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "generation_topics_user_id_idx": {
+ "name": "generation_topics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generation_topics_workspace_id_idx": {
+ "name": "generation_topics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generation_topics_workspace_visibility_idx": {
+ "name": "generation_topics_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "generation_topics_user_id_users_id_fk": {
+ "name": "generation_topics_user_id_users_id_fk",
+ "tableFrom": "generation_topics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generation_topics_workspace_id_workspaces_id_fk": {
+ "name": "generation_topics_workspace_id_workspaces_id_fk",
+ "tableFrom": "generation_topics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.generations": {
+ "name": "generations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "generation_batch_id": {
+ "name": "generation_batch_id",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "async_task_id": {
+ "name": "async_task_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seed": {
+ "name": "seed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "asset": {
+ "name": "asset",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "generations_user_id_idx": {
+ "name": "generations_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generations_batch_id_idx": {
+ "name": "generations_batch_id_idx",
+ "columns": [
+ {
+ "expression": "generation_batch_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generations_file_id_idx": {
+ "name": "generations_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "generations_workspace_id_idx": {
+ "name": "generations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "generations_user_id_users_id_fk": {
+ "name": "generations_user_id_users_id_fk",
+ "tableFrom": "generations",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generations_workspace_id_workspaces_id_fk": {
+ "name": "generations_workspace_id_workspaces_id_fk",
+ "tableFrom": "generations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generations_generation_batch_id_generation_batches_id_fk": {
+ "name": "generations_generation_batch_id_generation_batches_id_fk",
+ "tableFrom": "generations",
+ "tableTo": "generation_batches",
+ "columnsFrom": ["generation_batch_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "generations_async_task_id_async_tasks_id_fk": {
+ "name": "generations_async_task_id_async_tasks_id_fk",
+ "tableFrom": "generations",
+ "tableTo": "async_tasks",
+ "columnsFrom": ["async_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "generations_file_id_files_id_fk": {
+ "name": "generations_file_id_files_id_fk",
+ "tableFrom": "generations",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.goals": {
+ "name": "goals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requirement": {
+ "name": "requirement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_rounds": {
+ "name": "max_rounds",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_total_cost": {
+ "name": "max_total_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planning'"
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_id": {
+ "name": "subject_id",
+ "type": "text",
+ "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
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goals_user_id_idx": {
+ "name": "goals_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goals_workspace_id_idx": {
+ "name": "goals_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goals_agent_id_idx": {
+ "name": "goals_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goals_project_id_idx": {
+ "name": "goals_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goals_status_idx": {
+ "name": "goals_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goals_subject_idx": {
+ "name": "goals_subject_idx",
+ "columns": [
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goals_user_id_users_id_fk": {
+ "name": "goals_user_id_users_id_fk",
+ "tableFrom": "goals",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goals_workspace_id_workspaces_id_fk": {
+ "name": "goals_workspace_id_workspaces_id_fk",
+ "tableFrom": "goals",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goals_agent_id_agents_id_fk": {
+ "name": "goals_agent_id_agents_id_fk",
+ "tableFrom": "goals",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "goals_project_id_projects_id_fk": {
+ "name": "goals_project_id_projects_id_fk",
+ "tableFrom": "goals",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.goal_edges": {
+ "name": "goal_edges",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "goal_id": {
+ "name": "goal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_node_id": {
+ "name": "source_node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_node_id": {
+ "name": "target_node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_edges_source_target_kind_unique": {
+ "name": "goal_edges_source_target_kind_unique",
+ "columns": [
+ {
+ "expression": "source_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "target_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_edges_goal_id_idx": {
+ "name": "goal_edges_goal_id_idx",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_edges_target_node_id_idx": {
+ "name": "goal_edges_target_node_id_idx",
+ "columns": [
+ {
+ "expression": "target_node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_edges_goal_id_goals_id_fk": {
+ "name": "goal_edges_goal_id_goals_id_fk",
+ "tableFrom": "goal_edges",
+ "tableTo": "goals",
+ "columnsFrom": ["goal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_edges_goal_source_node_fk": {
+ "name": "goal_edges_goal_source_node_fk",
+ "tableFrom": "goal_edges",
+ "tableTo": "goal_nodes",
+ "columnsFrom": ["goal_id", "source_node_id"],
+ "columnsTo": ["goal_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_edges_goal_target_node_fk": {
+ "name": "goal_edges_goal_target_node_fk",
+ "tableFrom": "goal_edges",
+ "tableTo": "goal_nodes",
+ "columnsFrom": ["goal_id", "target_node_id"],
+ "columnsTo": ["goal_id", "id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "goal_edges_distinct_nodes": {
+ "name": "goal_edges_distinct_nodes",
+ "value": "\"goal_edges\".\"source_node_id\" <> \"goal_edges\".\"target_node_id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.goal_events": {
+ "name": "goal_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "goal_id": {
+ "name": "goal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_type": {
+ "name": "entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entity_id": {
+ "name": "entity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_events_goal_id_created_at_idx": {
+ "name": "goal_events_goal_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_events_entity_idx": {
+ "name": "goal_events_entity_idx",
+ "columns": [
+ {
+ "expression": "entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entity_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_events_task_id_idx": {
+ "name": "goal_events_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_events_operation_id_idx": {
+ "name": "goal_events_operation_id_idx",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_events_goal_id_goals_id_fk": {
+ "name": "goal_events_goal_id_goals_id_fk",
+ "tableFrom": "goal_events",
+ "tableTo": "goals",
+ "columnsFrom": ["goal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_events_task_id_tasks_id_fk": {
+ "name": "goal_events_task_id_tasks_id_fk",
+ "tableFrom": "goal_events",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.goal_node_decisions": {
+ "name": "goal_node_decisions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "node_id": {
+ "name": "node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "authority": {
+ "name": "authority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "question": {
+ "name": "question",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recommended_option_id": {
+ "name": "recommended_option_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_id": {
+ "name": "requested_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_project_role": {
+ "name": "requested_project_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_option_id": {
+ "name": "resolved_option_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolution": {
+ "name": "resolution",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_by_user_id": {
+ "name": "resolved_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_by_agent_id": {
+ "name": "resolved_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "canceled_at": {
+ "name": "canceled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_node_decisions_node_id_unique": {
+ "name": "goal_node_decisions_node_id_unique",
+ "columns": [
+ {
+ "expression": "node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_node_decisions_status_idx": {
+ "name": "goal_node_decisions_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_node_decisions_resolved_by_user_id_idx": {
+ "name": "goal_node_decisions_resolved_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "resolved_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_node_decisions_requested_user_id_status_idx": {
+ "name": "goal_node_decisions_requested_user_id_status_idx",
+ "columns": [
+ {
+ "expression": "requested_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_node_decisions_node_id_goal_nodes_id_fk": {
+ "name": "goal_node_decisions_node_id_goal_nodes_id_fk",
+ "tableFrom": "goal_node_decisions",
+ "tableTo": "goal_nodes",
+ "columnsFrom": ["node_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_node_decisions_requested_user_id_users_id_fk": {
+ "name": "goal_node_decisions_requested_user_id_users_id_fk",
+ "tableFrom": "goal_node_decisions",
+ "tableTo": "users",
+ "columnsFrom": ["requested_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "goal_node_decisions_resolved_by_user_id_users_id_fk": {
+ "name": "goal_node_decisions_resolved_by_user_id_users_id_fk",
+ "tableFrom": "goal_node_decisions",
+ "tableTo": "users",
+ "columnsFrom": ["resolved_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "goal_node_decisions_resolved_by_agent_id_agents_id_fk": {
+ "name": "goal_node_decisions_resolved_by_agent_id_agents_id_fk",
+ "tableFrom": "goal_node_decisions",
+ "tableTo": "agents",
+ "columnsFrom": ["resolved_by_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.goal_node_work_versions": {
+ "name": "goal_node_work_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "node_id": {
+ "name": "node_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "work_version_id": {
+ "name": "work_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "relation": {
+ "name": "relation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_node_work_versions_node_version_relation_unique": {
+ "name": "goal_node_work_versions_node_version_relation_unique",
+ "columns": [
+ {
+ "expression": "node_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "work_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "relation",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_node_work_versions_work_version_id_idx": {
+ "name": "goal_node_work_versions_work_version_id_idx",
+ "columns": [
+ {
+ "expression": "work_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_node_work_versions_node_id_goal_nodes_id_fk": {
+ "name": "goal_node_work_versions_node_id_goal_nodes_id_fk",
+ "tableFrom": "goal_node_work_versions",
+ "tableTo": "goal_nodes",
+ "columnsFrom": ["node_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_node_work_versions_work_version_id_work_versions_id_fk": {
+ "name": "goal_node_work_versions_work_version_id_work_versions_id_fk",
+ "tableFrom": "goal_node_work_versions",
+ "tableTo": "work_versions",
+ "columnsFrom": ["work_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.goal_nodes": {
+ "name": "goal_nodes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "goal_id": {
+ "name": "goal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'proposed'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(4, 3)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_agent_id": {
+ "name": "created_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_nodes_goal_id_status_idx": {
+ "name": "goal_nodes_goal_id_status_idx",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_nodes_created_by_user_id_idx": {
+ "name": "goal_nodes_created_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_nodes_goal_id_kind_idx": {
+ "name": "goal_nodes_goal_id_kind_idx",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_nodes_task_id_unique": {
+ "name": "goal_nodes_task_id_unique",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"goal_nodes\".\"task_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_nodes_goal_id_goals_id_fk": {
+ "name": "goal_nodes_goal_id_goals_id_fk",
+ "tableFrom": "goal_nodes",
+ "tableTo": "goals",
+ "columnsFrom": ["goal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_nodes_task_id_tasks_id_fk": {
+ "name": "goal_nodes_task_id_tasks_id_fk",
+ "tableFrom": "goal_nodes",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "goal_nodes_created_by_user_id_users_id_fk": {
+ "name": "goal_nodes_created_by_user_id_users_id_fk",
+ "tableFrom": "goal_nodes",
+ "tableTo": "users",
+ "columnsFrom": ["created_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "goal_nodes_created_by_agent_id_agents_id_fk": {
+ "name": "goal_nodes_created_by_agent_id_agents_id_fk",
+ "tableFrom": "goal_nodes",
+ "tableTo": "agents",
+ "columnsFrom": ["created_by_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "goal_nodes_goal_id_id_unique": {
+ "name": "goal_nodes_goal_id_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["goal_id", "id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "goal_nodes_confidence_range": {
+ "name": "goal_nodes_confidence_range",
+ "value": "\"goal_nodes\".\"confidence\" IS NULL OR (\"goal_nodes\".\"confidence\" >= 0 AND \"goal_nodes\".\"confidence\" <= 1)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.goal_subscriptions": {
+ "name": "goal_subscriptions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "goal_id": {
+ "name": "goal_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "widget_id": {
+ "name": "widget_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metric_id": {
+ "name": "metric_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "confirmed_version_id": {
+ "name": "confirmed_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "binding_revision": {
+ "name": "binding_revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "binding": {
+ "name": "binding",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wake_condition": {
+ "name": "wake_condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "freshness_policy": {
+ "name": "freshness_policy",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cursor": {
+ "name": "cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_subscriptions_goal_widget_metric_unique": {
+ "name": "goal_subscriptions_goal_widget_metric_unique",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "metric_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"goal_subscriptions\".\"metric_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_goal_widget_result_unique": {
+ "name": "goal_subscriptions_goal_widget_result_unique",
+ "columns": [
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"goal_subscriptions\".\"metric_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_widget_enabled_idx": {
+ "name": "goal_subscriptions_widget_enabled_idx",
+ "columns": [
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"goal_subscriptions\".\"enabled\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_personal_idx": {
+ "name": "goal_subscriptions_personal_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"goal_subscriptions\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_workspace_idx": {
+ "name": "goal_subscriptions_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "goal_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_metric_id_idx": {
+ "name": "goal_subscriptions_metric_id_idx",
+ "columns": [
+ {
+ "expression": "metric_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_confirmed_version_id_idx": {
+ "name": "goal_subscriptions_confirmed_version_id_idx",
+ "columns": [
+ {
+ "expression": "confirmed_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_subscriptions_reconcile_idx": {
+ "name": "goal_subscriptions_reconcile_idx",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"goal_subscriptions\".\"enabled\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_subscriptions_goal_id_goals_id_fk": {
+ "name": "goal_subscriptions_goal_id_goals_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "goals",
+ "columnsFrom": ["goal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_subscriptions_widget_id_widgets_id_fk": {
+ "name": "goal_subscriptions_widget_id_widgets_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "widgets",
+ "columnsFrom": ["widget_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_subscriptions_metric_id_metrics_id_fk": {
+ "name": "goal_subscriptions_metric_id_metrics_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "metrics",
+ "columnsFrom": ["metric_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_subscriptions_user_id_users_id_fk": {
+ "name": "goal_subscriptions_user_id_users_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_subscriptions_workspace_id_workspaces_id_fk": {
+ "name": "goal_subscriptions_workspace_id_workspaces_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "goal_subscriptions_confirmed_version_id_widget_versions_id_fk": {
+ "name": "goal_subscriptions_confirmed_version_id_widget_versions_id_fk",
+ "tableFrom": "goal_subscriptions",
+ "tableTo": "widget_versions",
+ "columnsFrom": ["confirmed_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "goal_subscriptions_binding_revision_positive": {
+ "name": "goal_subscriptions_binding_revision_positive",
+ "value": "\"goal_subscriptions\".\"binding_revision\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.goal_traces": {
+ "name": "goal_traces",
+ "schema": "",
+ "columns": {
+ "goal_id": {
+ "name": "goal_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "trace_s3_key": {
+ "name": "trace_s3_key",
+ "type": "text",
+ "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
+ },
+ "final_status": {
+ "name": "final_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "advances_total": {
+ "name": "advances_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ticks_total": {
+ "name": "ticks_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "advances_by_trigger": {
+ "name": "advances_by_trigger",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "advances_by_outcome": {
+ "name": "advances_by_outcome",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ticks_by_branch": {
+ "name": "ticks_by_branch",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "work_operations": {
+ "name": "work_operations",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "nodes_total": {
+ "name": "nodes_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "work_resolved": {
+ "name": "work_resolved",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "work_retired": {
+ "name": "work_retired",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "findings_total": {
+ "name": "findings_total",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gates_opened": {
+ "name": "gates_opened",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "gates_resolved": {
+ "name": "gates_resolved",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "human_waiting_ms": {
+ "name": "human_waiting_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "goal_traces_started_at_idx": {
+ "name": "goal_traces_started_at_idx",
+ "columns": [
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "goal_traces_final_status_idx": {
+ "name": "goal_traces_final_status_idx",
+ "columns": [
+ {
+ "expression": "final_status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "goal_traces_goal_id_goals_id_fk": {
+ "name": "goal_traces_goal_id_goals_id_fk",
+ "tableFrom": "goal_traces",
+ "tableTo": "goals",
+ "columnsFrom": ["goal_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.linear_connections": {
+ "name": "linear_connections",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_name": {
+ "name": "organization_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_url_key": {
+ "name": "organization_url_key",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_external_id": {
+ "name": "actor_external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "linear_connections_org_personal_unique": {
+ "name": "linear_connections_org_personal_unique",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"linear_connections\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_connections_org_workspace_unique": {
+ "name": "linear_connections_org_workspace_unique",
+ "columns": [
+ {
+ "expression": "organization_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"linear_connections\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_connections_user_id_idx": {
+ "name": "linear_connections_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "linear_connections_workspace_id_idx": {
+ "name": "linear_connections_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "linear_connections_user_id_users_id_fk": {
+ "name": "linear_connections_user_id_users_id_fk",
+ "tableFrom": "linear_connections",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "linear_connections_workspace_id_workspaces_id_fk": {
+ "name": "linear_connections_workspace_id_workspaces_id_fk",
+ "tableFrom": "linear_connections",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.llm_generation_tracing": {
+ "name": "llm_generation_tracing",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "scenario": {
+ "name": "scenario",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt_version": {
+ "name": "prompt_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt_hash": {
+ "name": "prompt_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "schema_name": {
+ "name": "schema_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_tracing_id": {
+ "name": "parent_tracing_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "success": {
+ "name": "success",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error_code": {
+ "name": "error_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_detail": {
+ "name": "error_detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "validation_failed": {
+ "name": "validation_failed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "input_hash": {
+ "name": "input_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_hint": {
+ "name": "input_hint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency_ms": {
+ "name": "latency_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost_usd": {
+ "name": "cost_usd",
+ "type": "numeric(12, 8)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "storage_key": {
+ "name": "storage_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_signal": {
+ "name": "feedback_signal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_score": {
+ "name": "feedback_score",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_source": {
+ "name": "feedback_source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_data": {
+ "name": "feedback_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_updated_at": {
+ "name": "feedback_updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trace_id": {
+ "name": "trace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "span_id": {
+ "name": "span_id",
+ "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": "now()"
+ }
+ },
+ "indexes": {
+ "llm_generation_tracing_scenario_idx": {
+ "name": "llm_generation_tracing_scenario_idx",
+ "columns": [
+ {
+ "expression": "scenario",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_prompt_version_idx": {
+ "name": "llm_generation_tracing_prompt_version_idx",
+ "columns": [
+ {
+ "expression": "prompt_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_user_id_idx": {
+ "name": "llm_generation_tracing_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_agent_id_idx": {
+ "name": "llm_generation_tracing_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_topic_id_idx": {
+ "name": "llm_generation_tracing_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_workspace_id_idx": {
+ "name": "llm_generation_tracing_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_provider_idx": {
+ "name": "llm_generation_tracing_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_model_idx": {
+ "name": "llm_generation_tracing_model_idx",
+ "columns": [
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_success_idx": {
+ "name": "llm_generation_tracing_success_idx",
+ "columns": [
+ {
+ "expression": "success",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_error_code_idx": {
+ "name": "llm_generation_tracing_error_code_idx",
+ "columns": [
+ {
+ "expression": "error_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_validation_failed_idx": {
+ "name": "llm_generation_tracing_validation_failed_idx",
+ "columns": [
+ {
+ "expression": "validation_failed",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_feedback_signal_idx": {
+ "name": "llm_generation_tracing_feedback_signal_idx",
+ "columns": [
+ {
+ "expression": "feedback_signal",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "llm_generation_tracing_created_at_idx": {
+ "name": "llm_generation_tracing_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "llm_generation_tracing_workspace_id_workspaces_id_fk": {
+ "name": "llm_generation_tracing_workspace_id_workspaces_id_fk",
+ "tableFrom": "llm_generation_tracing",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_chunks": {
+ "name": "message_chunks",
+ "schema": "",
+ "columns": {
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_id": {
+ "name": "chunk_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_chunks_user_id_idx": {
+ "name": "message_chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_chunks_message_id_idx": {
+ "name": "message_chunks_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_chunks_workspace_id_idx": {
+ "name": "message_chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_chunks_message_id_messages_id_fk": {
+ "name": "message_chunks_message_id_messages_id_fk",
+ "tableFrom": "message_chunks",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_chunks_chunk_id_chunks_id_fk": {
+ "name": "message_chunks_chunk_id_chunks_id_fk",
+ "tableFrom": "message_chunks",
+ "tableTo": "chunks",
+ "columnsFrom": ["chunk_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_chunks_user_id_users_id_fk": {
+ "name": "message_chunks_user_id_users_id_fk",
+ "tableFrom": "message_chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_chunks_workspace_id_workspaces_id_fk": {
+ "name": "message_chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "message_chunks_chunk_id_message_id_pk": {
+ "name": "message_chunks_chunk_id_message_id_pk",
+ "columns": ["chunk_id", "message_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_groups": {
+ "name": "message_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_group_id": {
+ "name": "parent_group_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_message_id": {
+ "name": "parent_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "message_groups_client_id_user_id_unique": {
+ "name": "message_groups_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_user_id_idx": {
+ "name": "message_groups_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_topic_id_idx": {
+ "name": "message_groups_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_type_idx": {
+ "name": "message_groups_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_parent_group_id_idx": {
+ "name": "message_groups_parent_group_id_idx",
+ "columns": [
+ {
+ "expression": "parent_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_parent_message_id_idx": {
+ "name": "message_groups_parent_message_id_idx",
+ "columns": [
+ {
+ "expression": "parent_message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_groups_workspace_id_idx": {
+ "name": "message_groups_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_groups_topic_id_topics_id_fk": {
+ "name": "message_groups_topic_id_topics_id_fk",
+ "tableFrom": "message_groups",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_groups_user_id_users_id_fk": {
+ "name": "message_groups_user_id_users_id_fk",
+ "tableFrom": "message_groups",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_groups_workspace_id_workspaces_id_fk": {
+ "name": "message_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_groups_parent_group_id_message_groups_id_fk": {
+ "name": "message_groups_parent_group_id_message_groups_id_fk",
+ "tableFrom": "message_groups",
+ "tableTo": "message_groups",
+ "columnsFrom": ["parent_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_groups_parent_message_id_messages_id_fk": {
+ "name": "message_groups_parent_message_id_messages_id_fk",
+ "tableFrom": "message_groups",
+ "tableTo": "messages",
+ "columnsFrom": ["parent_message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_plugins": {
+ "name": "message_plugins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'default'"
+ },
+ "intervention": {
+ "name": "intervention",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_name": {
+ "name": "api_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "arguments": {
+ "name": "arguments",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state": {
+ "name": "state",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_plugins_client_id_user_id_unique": {
+ "name": "message_plugins_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_plugins_user_id_idx": {
+ "name": "message_plugins_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_plugins_tool_call_id_idx": {
+ "name": "message_plugins_tool_call_id_idx",
+ "columns": [
+ {
+ "expression": "tool_call_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_plugins_workspace_id_idx": {
+ "name": "message_plugins_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_plugins_id_messages_id_fk": {
+ "name": "message_plugins_id_messages_id_fk",
+ "tableFrom": "message_plugins",
+ "tableTo": "messages",
+ "columnsFrom": ["id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_plugins_user_id_users_id_fk": {
+ "name": "message_plugins_user_id_users_id_fk",
+ "tableFrom": "message_plugins",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_plugins_workspace_id_workspaces_id_fk": {
+ "name": "message_plugins_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_plugins",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_queries": {
+ "name": "message_queries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rewrite_query": {
+ "name": "rewrite_query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_query": {
+ "name": "user_query",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "embeddings_id": {
+ "name": "embeddings_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_queries_client_id_user_id_unique": {
+ "name": "message_queries_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_queries_user_id_idx": {
+ "name": "message_queries_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_queries_message_id_idx": {
+ "name": "message_queries_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_queries_embeddings_id_idx": {
+ "name": "message_queries_embeddings_id_idx",
+ "columns": [
+ {
+ "expression": "embeddings_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_queries_workspace_id_idx": {
+ "name": "message_queries_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_queries_message_id_messages_id_fk": {
+ "name": "message_queries_message_id_messages_id_fk",
+ "tableFrom": "message_queries",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_queries_user_id_users_id_fk": {
+ "name": "message_queries_user_id_users_id_fk",
+ "tableFrom": "message_queries",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_queries_workspace_id_workspaces_id_fk": {
+ "name": "message_queries_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_queries",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_queries_embeddings_id_embeddings_id_fk": {
+ "name": "message_queries_embeddings_id_embeddings_id_fk",
+ "tableFrom": "message_queries",
+ "tableTo": "embeddings",
+ "columnsFrom": ["embeddings_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_query_chunks": {
+ "name": "message_query_chunks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "query_id": {
+ "name": "query_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_id": {
+ "name": "chunk_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "similarity": {
+ "name": "similarity",
+ "type": "numeric(6, 5)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_query_chunks_user_id_idx": {
+ "name": "message_query_chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_query_chunks_message_id_idx": {
+ "name": "message_query_chunks_message_id_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_query_chunks_query_id_idx": {
+ "name": "message_query_chunks_query_id_idx",
+ "columns": [
+ {
+ "expression": "query_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_query_chunks_workspace_id_idx": {
+ "name": "message_query_chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_query_chunks_id_messages_id_fk": {
+ "name": "message_query_chunks_id_messages_id_fk",
+ "tableFrom": "message_query_chunks",
+ "tableTo": "messages",
+ "columnsFrom": ["id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_query_chunks_query_id_message_queries_id_fk": {
+ "name": "message_query_chunks_query_id_message_queries_id_fk",
+ "tableFrom": "message_query_chunks",
+ "tableTo": "message_queries",
+ "columnsFrom": ["query_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_query_chunks_chunk_id_chunks_id_fk": {
+ "name": "message_query_chunks_chunk_id_chunks_id_fk",
+ "tableFrom": "message_query_chunks",
+ "tableTo": "chunks",
+ "columnsFrom": ["chunk_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_query_chunks_user_id_users_id_fk": {
+ "name": "message_query_chunks_user_id_users_id_fk",
+ "tableFrom": "message_query_chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_query_chunks_workspace_id_workspaces_id_fk": {
+ "name": "message_query_chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_query_chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "message_query_chunks_chunk_id_id_query_id_pk": {
+ "name": "message_query_chunks_chunk_id_id_query_id_pk",
+ "columns": ["chunk_id", "id", "query_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_tts": {
+ "name": "message_tts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "content_md5": {
+ "name": "content_md5",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "voice": {
+ "name": "voice",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_tts_client_id_user_id_unique": {
+ "name": "message_tts_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_tts_user_id_idx": {
+ "name": "message_tts_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_tts_workspace_id_idx": {
+ "name": "message_tts_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_tts_id_messages_id_fk": {
+ "name": "message_tts_id_messages_id_fk",
+ "tableFrom": "message_tts",
+ "tableTo": "messages",
+ "columnsFrom": ["id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_tts_file_id_files_id_fk": {
+ "name": "message_tts_file_id_files_id_fk",
+ "tableFrom": "message_tts",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_tts_user_id_users_id_fk": {
+ "name": "message_tts_user_id_users_id_fk",
+ "tableFrom": "message_tts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_tts_workspace_id_workspaces_id_fk": {
+ "name": "message_tts_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_tts",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.message_translates": {
+ "name": "message_translates",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "from": {
+ "name": "from",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "to": {
+ "name": "to",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "message_translates_client_id_user_id_unique": {
+ "name": "message_translates_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_translates_user_id_idx": {
+ "name": "message_translates_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_translates_workspace_id_idx": {
+ "name": "message_translates_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "message_translates_id_messages_id_fk": {
+ "name": "message_translates_id_messages_id_fk",
+ "tableFrom": "message_translates",
+ "tableTo": "messages",
+ "columnsFrom": ["id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_translates_user_id_users_id_fk": {
+ "name": "message_translates_user_id_users_id_fk",
+ "tableFrom": "message_translates",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "message_translates_workspace_id_workspaces_id_fk": {
+ "name": "message_translates_workspace_id_workspaces_id_fk",
+ "tableFrom": "message_translates",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.messages": {
+ "name": "messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning": {
+ "name": "reasoning",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "search": {
+ "name": "search",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage": {
+ "name": "usage",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "favorite": {
+ "name": "favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools": {
+ "name": "tools",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trace_id": {
+ "name": "trace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "observation_id": {
+ "name": "observation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "quota_id": {
+ "name": "quota_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_group_id": {
+ "name": "message_group_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "messages_created_at_idx": {
+ "name": "messages_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "message_client_id_user_unique": {
+ "name": "message_client_id_user_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_topic_id_idx": {
+ "name": "messages_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_topic_id_updated_at_idx": {
+ "name": "messages_topic_id_updated_at_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_parent_id_idx": {
+ "name": "messages_parent_id_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_quota_id_idx": {
+ "name": "messages_quota_id_idx",
+ "columns": [
+ {
+ "expression": "quota_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_user_id_idx": {
+ "name": "messages_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_session_id_idx": {
+ "name": "messages_session_id_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_thread_id_idx": {
+ "name": "messages_thread_id_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_agent_id_idx": {
+ "name": "messages_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_group_id_idx": {
+ "name": "messages_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_message_group_id_idx": {
+ "name": "messages_message_group_id_idx",
+ "columns": [
+ {
+ "expression": "message_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_usage_cost_idx": {
+ "name": "messages_usage_cost_idx",
+ "columns": [
+ {
+ "expression": "((\"usage\"->>'cost')::numeric)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_usage_total_tokens_idx": {
+ "name": "messages_usage_total_tokens_idx",
+ "columns": [
+ {
+ "expression": "((\"usage\"->>'totalTokens')::numeric)",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_workspace_id_idx": {
+ "name": "messages_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messages_user_id_users_id_fk": {
+ "name": "messages_user_id_users_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_session_id_sessions_id_fk": {
+ "name": "messages_session_id_sessions_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_topic_id_topics_id_fk": {
+ "name": "messages_topic_id_topics_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_thread_id_threads_id_fk": {
+ "name": "messages_thread_id_threads_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "threads",
+ "columnsFrom": ["thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_parent_id_messages_id_fk": {
+ "name": "messages_parent_id_messages_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "messages",
+ "columnsFrom": ["parent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "messages_quota_id_messages_id_fk": {
+ "name": "messages_quota_id_messages_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "messages",
+ "columnsFrom": ["quota_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "messages_agent_id_agents_id_fk": {
+ "name": "messages_agent_id_agents_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_group_id_chat_groups_id_fk": {
+ "name": "messages_group_id_chat_groups_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "messages_message_group_id_message_groups_id_fk": {
+ "name": "messages_message_group_id_message_groups_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "message_groups",
+ "columnsFrom": ["message_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_workspace_id_workspaces_id_fk": {
+ "name": "messages_workspace_id_workspaces_id_fk",
+ "tableFrom": "messages",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.messages_files": {
+ "name": "messages_files",
+ "schema": "",
+ "columns": {
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "messages_files_user_id_idx": {
+ "name": "messages_files_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_files_message_id_idx": {
+ "name": "messages_files_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messages_files_workspace_id_idx": {
+ "name": "messages_files_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messages_files_file_id_files_id_fk": {
+ "name": "messages_files_file_id_files_id_fk",
+ "tableFrom": "messages_files",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_files_message_id_messages_id_fk": {
+ "name": "messages_files_message_id_messages_id_fk",
+ "tableFrom": "messages_files",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_files_user_id_users_id_fk": {
+ "name": "messages_files_user_id_users_id_fk",
+ "tableFrom": "messages_files",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messages_files_workspace_id_workspaces_id_fk": {
+ "name": "messages_files_workspace_id_workspaces_id_fk",
+ "tableFrom": "messages_files",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "messages_files_file_id_message_id_pk": {
+ "name": "messages_files_file_id_message_id_pk",
+ "columns": ["file_id", "message_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.messenger_account_links": {
+ "name": "messenger_account_links",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "platform": {
+ "name": "platform",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenant_id": {
+ "name": "tenant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "platform_user_id": {
+ "name": "platform_user_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform_username": {
+ "name": "platform_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_id": {
+ "name": "application_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active_agent_id": {
+ "name": "active_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "messenger_account_links_platform_tenant_user_unique": {
+ "name": "messenger_account_links_platform_tenant_user_unique",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tenant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_account_links_user_platform_tenant_unique": {
+ "name": "messenger_account_links_user_platform_tenant_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tenant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_account_links_platform_tenant_application_unique": {
+ "name": "messenger_account_links_platform_tenant_application_unique",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tenant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "application_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"messenger_account_links\".\"application_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_account_links_active_agent_idx": {
+ "name": "messenger_account_links_active_agent_idx",
+ "columns": [
+ {
+ "expression": "active_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_account_links_workspace_id_idx": {
+ "name": "messenger_account_links_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messenger_account_links_user_id_users_id_fk": {
+ "name": "messenger_account_links_user_id_users_id_fk",
+ "tableFrom": "messenger_account_links",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messenger_account_links_workspace_id_workspaces_id_fk": {
+ "name": "messenger_account_links_workspace_id_workspaces_id_fk",
+ "tableFrom": "messenger_account_links",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "messenger_account_links_active_agent_id_agents_id_fk": {
+ "name": "messenger_account_links_active_agent_id_agents_id_fk",
+ "tableFrom": "messenger_account_links",
+ "tableTo": "agents",
+ "columnsFrom": ["active_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.messenger_installations": {
+ "name": "messenger_installations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "platform": {
+ "name": "platform",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tenant_id": {
+ "name": "tenant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "application_id": {
+ "name": "application_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_by_user_id": {
+ "name": "installed_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_by_platform_user_id": {
+ "name": "installed_by_platform_user_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "messenger_installations_platform_app_tenant_unique": {
+ "name": "messenger_installations_platform_app_tenant_unique",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "application_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tenant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_installations_platform_tenant_idx": {
+ "name": "messenger_installations_platform_tenant_idx",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tenant_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "messenger_installations_token_expires_at_idx": {
+ "name": "messenger_installations_token_expires_at_idx",
+ "columns": [
+ {
+ "expression": "token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "messenger_installations_installed_by_user_id_users_id_fk": {
+ "name": "messenger_installations_installed_by_user_id_users_id_fk",
+ "tableFrom": "messenger_installations",
+ "tableTo": "users",
+ "columnsFrom": ["installed_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.metric_points": {
+ "name": "metric_points",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "metric_id": {
+ "name": "metric_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value": {
+ "name": "value",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "observed_at": {
+ "name": "observed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_type": {
+ "name": "actor_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_id": {
+ "name": "actor_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "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": "now()"
+ }
+ },
+ "indexes": {
+ "metric_points_series_time_idx": {
+ "name": "metric_points_series_time_idx",
+ "columns": [
+ {
+ "expression": "metric_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "observed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "metric_points_user_id_idx": {
+ "name": "metric_points_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "metric_points_workspace_id_idx": {
+ "name": "metric_points_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "metric_points_metric_id_metrics_id_fk": {
+ "name": "metric_points_metric_id_metrics_id_fk",
+ "tableFrom": "metric_points",
+ "tableTo": "metrics",
+ "columnsFrom": ["metric_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "metric_points_user_id_users_id_fk": {
+ "name": "metric_points_user_id_users_id_fk",
+ "tableFrom": "metric_points",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "metric_points_workspace_id_workspaces_id_fk": {
+ "name": "metric_points_workspace_id_workspaces_id_fk",
+ "tableFrom": "metric_points",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.metrics": {
+ "name": "metrics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject_id": {
+ "name": "subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'gauge'"
+ },
+ "unit": {
+ "name": "unit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "metrics_subject_key_unique": {
+ "name": "metrics_subject_key_unique",
+ "columns": [
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "metrics_user_id_idx": {
+ "name": "metrics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "metrics_workspace_id_idx": {
+ "name": "metrics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "metrics_user_id_users_id_fk": {
+ "name": "metrics_user_id_users_id_fk",
+ "tableFrom": "metrics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "metrics_workspace_id_workspaces_id_fk": {
+ "name": "metrics_workspace_id_workspaces_id_fk",
+ "tableFrom": "metrics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.nextauth_accounts": {
+ "name": "nextauth_accounts",
+ "schema": "",
+ "columns": {
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "session_state": {
+ "name": "session_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "nextauth_accounts_user_id_idx": {
+ "name": "nextauth_accounts_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "nextauth_accounts_user_id_users_id_fk": {
+ "name": "nextauth_accounts_user_id_users_id_fk",
+ "tableFrom": "nextauth_accounts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "nextauth_accounts_provider_providerAccountId_pk": {
+ "name": "nextauth_accounts_provider_providerAccountId_pk",
+ "columns": ["provider", "providerAccountId"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.nextauth_authenticators": {
+ "name": "nextauth_authenticators",
+ "schema": "",
+ "columns": {
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentialBackedUp": {
+ "name": "credentialBackedUp",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentialDeviceType": {
+ "name": "credentialDeviceType",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentialID": {
+ "name": "credentialID",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentialPublicKey": {
+ "name": "credentialPublicKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "nextauth_authenticators_user_id_users_id_fk": {
+ "name": "nextauth_authenticators_user_id_users_id_fk",
+ "tableFrom": "nextauth_authenticators",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "nextauth_authenticators_user_id_credentialID_pk": {
+ "name": "nextauth_authenticators_user_id_credentialID_pk",
+ "columns": ["user_id", "credentialID"]
+ }
+ },
+ "uniqueConstraints": {
+ "nextauth_authenticators_credentialID_unique": {
+ "name": "nextauth_authenticators_credentialID_unique",
+ "nullsNotDistinct": false,
+ "columns": ["credentialID"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.nextauth_sessions": {
+ "name": "nextauth_sessions",
+ "schema": "",
+ "columns": {
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "nextauth_sessions_user_id_idx": {
+ "name": "nextauth_sessions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "nextauth_sessions_user_id_users_id_fk": {
+ "name": "nextauth_sessions_user_id_users_id_fk",
+ "tableFrom": "nextauth_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.nextauth_verificationtokens": {
+ "name": "nextauth_verificationtokens",
+ "schema": "",
+ "columns": {
+ "expires": {
+ "name": "expires",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "nextauth_verificationtokens_identifier_token_pk": {
+ "name": "nextauth_verificationtokens_identifier_token_pk",
+ "columns": ["identifier", "token"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification_deliveries": {
+ "name": "notification_deliveries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "notification_id": {
+ "name": "notification_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_message_id": {
+ "name": "provider_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failed_reason": {
+ "name": "failed_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sent_at": {
+ "name": "sent_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": "now()"
+ }
+ },
+ "indexes": {
+ "idx_deliveries_notification": {
+ "name": "idx_deliveries_notification",
+ "columns": [
+ {
+ "expression": "notification_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deliveries_channel": {
+ "name": "idx_deliveries_channel",
+ "columns": [
+ {
+ "expression": "channel",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_deliveries_status": {
+ "name": "idx_deliveries_status",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_deliveries_notification_id_notifications_id_fk": {
+ "name": "notification_deliveries_notification_id_notifications_id_fk",
+ "tableFrom": "notification_deliveries",
+ "tableTo": "notifications",
+ "columnsFrom": ["notification_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notifications": {
+ "name": "notifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "context": {
+ "name": "context",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_url": {
+ "name": "action_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_read": {
+ "name": "is_read",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_archived": {
+ "name": "is_archived",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_notifications_user": {
+ "name": "idx_notifications_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_user_active": {
+ "name": "idx_notifications_user_active",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notifications\".\"is_archived\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_user_unread": {
+ "name": "idx_notifications_user_unread",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notifications\".\"is_read\" = false AND \"notifications\".\"is_archived\" = false",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_dedupe": {
+ "name": "idx_notifications_dedupe",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "dedupe_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_user_workspace": {
+ "name": "idx_notifications_user_workspace",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_workspace_id": {
+ "name": "idx_notifications_workspace_id",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_notifications_archived_cleanup": {
+ "name": "idx_notifications_archived_cleanup",
+ "columns": [
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notifications\".\"is_archived\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notifications_user_id_users_id_fk": {
+ "name": "notifications_user_id_users_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notifications_workspace_id_workspaces_id_fk": {
+ "name": "notifications_workspace_id_workspaces_id_fk",
+ "tableFrom": "notifications",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_handoffs": {
+ "name": "oauth_handoffs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client": {
+ "name": "client",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_access_tokens": {
+ "name": "oidc_access_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_access_tokens_user_id_idx": {
+ "name": "oidc_access_tokens_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_access_tokens_user_id_users_id_fk": {
+ "name": "oidc_access_tokens_user_id_users_id_fk",
+ "tableFrom": "oidc_access_tokens",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_authorization_codes": {
+ "name": "oidc_authorization_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_authorization_codes_user_id_idx": {
+ "name": "oidc_authorization_codes_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_authorization_codes_user_id_users_id_fk": {
+ "name": "oidc_authorization_codes_user_id_users_id_fk",
+ "tableFrom": "oidc_authorization_codes",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_clients": {
+ "name": "oidc_clients",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grants": {
+ "name": "grants",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_type": {
+ "name": "application_type",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_uri": {
+ "name": "client_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "logo_uri": {
+ "name": "logo_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_uri": {
+ "name": "policy_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tos_uri": {
+ "name": "tos_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_first_party": {
+ "name": "is_first_party",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_clients_user_id_idx": {
+ "name": "oidc_clients_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oidc_clients_workspace_id_idx": {
+ "name": "oidc_clients_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_clients_user_id_users_id_fk": {
+ "name": "oidc_clients_user_id_users_id_fk",
+ "tableFrom": "oidc_clients",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oidc_clients_workspace_id_workspaces_id_fk": {
+ "name": "oidc_clients_workspace_id_workspaces_id_fk",
+ "tableFrom": "oidc_clients",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_consents": {
+ "name": "oidc_consents",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "oidc_consents_user_id_users_id_fk": {
+ "name": "oidc_consents_user_id_users_id_fk",
+ "tableFrom": "oidc_consents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oidc_consents_client_id_oidc_clients_id_fk": {
+ "name": "oidc_consents_client_id_oidc_clients_id_fk",
+ "tableFrom": "oidc_consents",
+ "tableTo": "oidc_clients",
+ "columnsFrom": ["client_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "oidc_consents_user_id_client_id_pk": {
+ "name": "oidc_consents_user_id_client_id_pk",
+ "columns": ["user_id", "client_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_device_codes": {
+ "name": "oidc_device_codes",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_code": {
+ "name": "user_code",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_device_codes_user_id_idx": {
+ "name": "oidc_device_codes_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_device_codes_user_id_users_id_fk": {
+ "name": "oidc_device_codes_user_id_users_id_fk",
+ "tableFrom": "oidc_device_codes",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_grants": {
+ "name": "oidc_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_grants_user_id_idx": {
+ "name": "oidc_grants_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_grants_user_id_users_id_fk": {
+ "name": "oidc_grants_user_id_users_id_fk",
+ "tableFrom": "oidc_grants",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_interactions": {
+ "name": "oidc_interactions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_refresh_tokens": {
+ "name": "oidc_refresh_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_id": {
+ "name": "grant_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_refresh_tokens_user_id_idx": {
+ "name": "oidc_refresh_tokens_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_refresh_tokens_user_id_users_id_fk": {
+ "name": "oidc_refresh_tokens_user_id_users_id_fk",
+ "tableFrom": "oidc_refresh_tokens",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oidc_sessions": {
+ "name": "oidc_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "data": {
+ "name": "data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "oidc_sessions_user_id_idx": {
+ "name": "oidc_sessions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oidc_sessions_user_id_users_id_fk": {
+ "name": "oidc_sessions_user_id_users_id_fk",
+ "tableFrom": "oidc_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_agents": {
+ "name": "project_agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "responsibility": {
+ "name": "responsibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_agents_project_id_agent_id_unique": {
+ "name": "project_agents_project_id_agent_id_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_agents_project_id_sort_order_idx": {
+ "name": "project_agents_project_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_agents_agent_id_idx": {
+ "name": "project_agents_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_agents_workspace_id_idx": {
+ "name": "project_agents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_agents_project_id_projects_id_fk": {
+ "name": "project_agents_project_id_projects_id_fk",
+ "tableFrom": "project_agents",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_agents_agent_id_agents_id_fk": {
+ "name": "project_agents_agent_id_agents_id_fk",
+ "tableFrom": "project_agents",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_agents_added_by_user_id_users_id_fk": {
+ "name": "project_agents_added_by_user_id_users_id_fk",
+ "tableFrom": "project_agents",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_agents_workspace_id_workspaces_id_fk": {
+ "name": "project_agents_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_agents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_chat_groups": {
+ "name": "project_chat_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chat_group_id": {
+ "name": "chat_group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "responsibility": {
+ "name": "responsibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_chat_groups_project_id_chat_group_id_unique": {
+ "name": "project_chat_groups_project_id_chat_group_id_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "chat_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_chat_groups_project_id_sort_order_idx": {
+ "name": "project_chat_groups_project_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_chat_groups_chat_group_id_idx": {
+ "name": "project_chat_groups_chat_group_id_idx",
+ "columns": [
+ {
+ "expression": "chat_group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_chat_groups_workspace_id_idx": {
+ "name": "project_chat_groups_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_chat_groups_project_id_projects_id_fk": {
+ "name": "project_chat_groups_project_id_projects_id_fk",
+ "tableFrom": "project_chat_groups",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_chat_groups_chat_group_id_chat_groups_id_fk": {
+ "name": "project_chat_groups_chat_group_id_chat_groups_id_fk",
+ "tableFrom": "project_chat_groups",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["chat_group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_chat_groups_added_by_user_id_users_id_fk": {
+ "name": "project_chat_groups_added_by_user_id_users_id_fk",
+ "tableFrom": "project_chat_groups",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_chat_groups_workspace_id_workspaces_id_fk": {
+ "name": "project_chat_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_chat_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_completion_reviews": {
+ "name": "project_completion_reviews",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reviewer_user_id": {
+ "name": "reviewer_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "round": {
+ "name": "round",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decision": {
+ "name": "decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "comment": {
+ "name": "comment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_completion_reviews_project_id_round_unique": {
+ "name": "project_completion_reviews_project_id_round_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "round",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_completion_reviews_project_id_created_at_idx": {
+ "name": "project_completion_reviews_project_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_completion_reviews_reviewer_user_id_idx": {
+ "name": "project_completion_reviews_reviewer_user_id_idx",
+ "columns": [
+ {
+ "expression": "reviewer_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_completion_reviews_workspace_id_idx": {
+ "name": "project_completion_reviews_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_completion_reviews_project_id_projects_id_fk": {
+ "name": "project_completion_reviews_project_id_projects_id_fk",
+ "tableFrom": "project_completion_reviews",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_completion_reviews_reviewer_user_id_users_id_fk": {
+ "name": "project_completion_reviews_reviewer_user_id_users_id_fk",
+ "tableFrom": "project_completion_reviews",
+ "tableTo": "users",
+ "columnsFrom": ["reviewer_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_completion_reviews_workspace_id_workspaces_id_fk": {
+ "name": "project_completion_reviews_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_completion_reviews",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_completion_reviews_round_positive": {
+ "name": "project_completion_reviews_round_positive",
+ "value": "\"project_completion_reviews\".\"round\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_knowledge_bases": {
+ "name": "project_knowledge_bases",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_knowledge_bases_project_id_knowledge_base_id_unique": {
+ "name": "project_knowledge_bases_project_id_knowledge_base_id_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "knowledge_base_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_knowledge_bases_project_id_sort_order_idx": {
+ "name": "project_knowledge_bases_project_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_knowledge_bases_knowledge_base_id_idx": {
+ "name": "project_knowledge_bases_knowledge_base_id_idx",
+ "columns": [
+ {
+ "expression": "knowledge_base_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_knowledge_bases_workspace_id_idx": {
+ "name": "project_knowledge_bases_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_knowledge_bases_project_id_projects_id_fk": {
+ "name": "project_knowledge_bases_project_id_projects_id_fk",
+ "tableFrom": "project_knowledge_bases",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "project_knowledge_bases_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "project_knowledge_bases",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_knowledge_bases_added_by_user_id_users_id_fk": {
+ "name": "project_knowledge_bases_added_by_user_id_users_id_fk",
+ "tableFrom": "project_knowledge_bases",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_knowledge_bases_workspace_id_workspaces_id_fk": {
+ "name": "project_knowledge_bases_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_knowledge_bases",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_working_directories": {
+ "name": "project_working_directories",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "path": {
+ "name": "path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permission": {
+ "name": "permission",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'readWrite'"
+ },
+ "is_primary": {
+ "name": "is_primary",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_working_directories_project_device_path_unique": {
+ "name": "project_working_directories_project_device_path_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "path",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_working_directories_project_primary_unique": {
+ "name": "project_working_directories_project_primary_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_working_directories\".\"is_primary\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_working_directories_project_sort_order_idx": {
+ "name": "project_working_directories_project_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_working_directories_device_id_idx": {
+ "name": "project_working_directories_device_id_idx",
+ "columns": [
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_working_directories_workspace_id_idx": {
+ "name": "project_working_directories_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_working_directories_project_id_projects_id_fk": {
+ "name": "project_working_directories_project_id_projects_id_fk",
+ "tableFrom": "project_working_directories",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_working_directories_device_id_devices_id_fk": {
+ "name": "project_working_directories_device_id_devices_id_fk",
+ "tableFrom": "project_working_directories",
+ "tableTo": "devices",
+ "columnsFrom": ["device_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_working_directories_workspace_id_workspaces_id_fk": {
+ "name": "project_working_directories_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_working_directories",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_working_directories_added_by_user_id_users_id_fk": {
+ "name": "project_working_directories_added_by_user_id_users_id_fk",
+ "tableFrom": "project_working_directories",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_working_directories_path_not_empty": {
+ "name": "project_working_directories_path_not_empty",
+ "value": "length(btrim(\"project_working_directories\".\"path\")) > 0"
+ },
+ "project_working_directories_name_not_empty": {
+ "name": "project_working_directories_name_not_empty",
+ "value": "length(btrim(\"project_working_directories\".\"name\")) > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.projects": {
+ "name": "projects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "varchar(6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "coordinator_agent_id": {
+ "name": "coordinator_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'backlog'"
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "completed_review_id": {
+ "name": "completed_review_id",
+ "type": "uuid",
+ "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
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "projects_slug_user_id_unique": {
+ "name": "projects_slug_user_id_unique",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_slug_workspace_id_unique": {
+ "name": "projects_slug_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_identifier_user_id_unique": {
+ "name": "projects_identifier_user_id_unique",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_identifier_workspace_id_unique": {
+ "name": "projects_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"projects\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_user_id_idx": {
+ "name": "projects_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_workspace_id_idx": {
+ "name": "projects_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_user_id_sort_order_idx": {
+ "name": "projects_user_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_workspace_id_sort_order_idx": {
+ "name": "projects_workspace_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_workspace_visibility_idx": {
+ "name": "projects_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_status_updated_at_idx": {
+ "name": "projects_status_updated_at_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "projects_coordinator_agent_id_idx": {
+ "name": "projects_coordinator_agent_id_idx",
+ "columns": [
+ {
+ "expression": "coordinator_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "projects_coordinator_agent_id_agents_id_fk": {
+ "name": "projects_coordinator_agent_id_agents_id_fk",
+ "tableFrom": "projects",
+ "tableTo": "agents",
+ "columnsFrom": ["coordinator_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "projects_user_id_users_id_fk": {
+ "name": "projects_user_id_users_id_fk",
+ "tableFrom": "projects",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "projects_workspace_id_workspaces_id_fk": {
+ "name": "projects_workspace_id_workspaces_id_fk",
+ "tableFrom": "projects",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "projects_completed_requires_human_review": {
+ "name": "projects_completed_requires_human_review",
+ "value": "\"projects\".\"status\" <> 'completed' OR (\"projects\".\"completed_review_id\" IS NOT NULL AND \"projects\".\"completed_at\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_environments": {
+ "name": "project_environments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "environment_id": {
+ "name": "environment_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default_instance_id": {
+ "name": "default_instance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_environments_default_instance_id_idx": {
+ "name": "project_environments_default_instance_id_idx",
+ "columns": [
+ {
+ "expression": "default_instance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_project_environment_unique": {
+ "name": "project_environments_project_environment_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "environment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_project_default_unique": {
+ "name": "project_environments_project_default_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"project_environments\".\"is_default\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_project_sort_order_idx": {
+ "name": "project_environments_project_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_environment_id_idx": {
+ "name": "project_environments_environment_id_idx",
+ "columns": [
+ {
+ "expression": "environment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_workspace_id_idx": {
+ "name": "project_environments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_environments_added_by_user_id_idx": {
+ "name": "project_environments_added_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "added_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_environments_project_id_projects_id_fk": {
+ "name": "project_environments_project_id_projects_id_fk",
+ "tableFrom": "project_environments",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_environments_environment_id_environments_id_fk": {
+ "name": "project_environments_environment_id_environments_id_fk",
+ "tableFrom": "project_environments",
+ "tableTo": "environments",
+ "columnsFrom": ["environment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ },
+ "project_environments_workspace_id_workspaces_id_fk": {
+ "name": "project_environments_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_environments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_environments_added_by_user_id_users_id_fk": {
+ "name": "project_environments_added_by_user_id_users_id_fk",
+ "tableFrom": "project_environments",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_environments_default_instance_fk": {
+ "name": "project_environments_default_instance_fk",
+ "tableFrom": "project_environments",
+ "tableTo": "environment_instances",
+ "columnsFrom": ["environment_id", "default_instance_id"],
+ "columnsTo": ["environment_id", "id"],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_environments_default_enabled": {
+ "name": "project_environments_default_enabled",
+ "value": "NOT \"project_environments\".\"is_default\" OR \"project_environments\".\"enabled\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_works": {
+ "name": "project_works",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "work_id": {
+ "name": "work_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "added_by_user_id": {
+ "name": "added_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_works_project_id_work_id_unique": {
+ "name": "project_works_project_id_work_id_unique",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "work_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_works_project_id_sort_order_idx": {
+ "name": "project_works_project_id_sort_order_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "sort_order",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_works_work_id_idx": {
+ "name": "project_works_work_id_idx",
+ "columns": [
+ {
+ "expression": "work_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_works_workspace_id_idx": {
+ "name": "project_works_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_works_project_id_projects_id_fk": {
+ "name": "project_works_project_id_projects_id_fk",
+ "tableFrom": "project_works",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_works_work_id_works_id_fk": {
+ "name": "project_works_work_id_works_id_fk",
+ "tableFrom": "project_works",
+ "tableTo": "works",
+ "columnsFrom": ["work_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_works_added_by_user_id_users_id_fk": {
+ "name": "project_works_added_by_user_id_users_id_fk",
+ "tableFrom": "project_works",
+ "tableTo": "users",
+ "columnsFrom": ["added_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_works_workspace_id_workspaces_id_fk": {
+ "name": "project_works_workspace_id_workspaces_id_fk",
+ "tableFrom": "project_works",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.push_live_activities": {
+ "name": "push_live_activities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "activity_key": {
+ "name": "activity_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "activity_id": {
+ "name": "activity_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "push_token": {
+ "name": "push_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "apns_environment": {
+ "name": "apns_environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_push_live_activities_user_device_activity": {
+ "name": "idx_push_live_activities_user_device_activity",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "activity_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_push_live_activities_user_activity": {
+ "name": "idx_push_live_activities_user_activity",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "activity_key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_push_live_activities_user_operation": {
+ "name": "idx_push_live_activities_user_operation",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_push_live_activities_last_seen": {
+ "name": "idx_push_live_activities_last_seen",
+ "columns": [
+ {
+ "expression": "last_seen_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "push_live_activities_user_id_users_id_fk": {
+ "name": "push_live_activities_user_id_users_id_fk",
+ "tableFrom": "push_live_activities",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "push_live_activities_apns_environment_check": {
+ "name": "push_live_activities_apns_environment_check",
+ "value": "\"push_live_activities\".\"apns_environment\" IN ('sandbox', 'production')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.push_tokens": {
+ "name": "push_tokens",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expo_token": {
+ "name": "expo_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "apns_environment": {
+ "name": "apns_environment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "app_version": {
+ "name": "app_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "live_activity_push_to_start_token": {
+ "name": "live_activity_push_to_start_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "idx_push_tokens_user_device": {
+ "name": "idx_push_tokens_user_device",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "device_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_push_tokens_user": {
+ "name": "idx_push_tokens_user",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "idx_push_tokens_last_seen": {
+ "name": "idx_push_tokens_last_seen",
+ "columns": [
+ {
+ "expression": "last_seen_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "push_tokens_user_id_users_id_fk": {
+ "name": "push_tokens_user_id_users_id_fk",
+ "tableFrom": "push_tokens",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "push_tokens_apns_environment_check": {
+ "name": "push_tokens_apns_environment_check",
+ "value": "\"push_tokens\".\"apns_environment\" IS NULL OR \"push_tokens\".\"apns_environment\" IN ('sandbox', 'production')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.chunks": {
+ "name": "chunks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "abstract": {
+ "name": "abstract",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "index": {
+ "name": "index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chunks_client_id_user_id_unique": {
+ "name": "chunks_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chunks_user_id_idx": {
+ "name": "chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "chunks_workspace_id_idx": {
+ "name": "chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chunks_user_id_users_id_fk": {
+ "name": "chunks_user_id_users_id_fk",
+ "tableFrom": "chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chunks_workspace_id_workspaces_id_fk": {
+ "name": "chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_chunks": {
+ "name": "document_chunks",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "varchar(30)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "chunk_id": {
+ "name": "chunk_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "page_index": {
+ "name": "page_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_chunks_document_id_idx": {
+ "name": "document_chunks_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_chunks_chunk_id_idx": {
+ "name": "document_chunks_chunk_id_idx",
+ "columns": [
+ {
+ "expression": "chunk_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_chunks_user_id_idx": {
+ "name": "document_chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "document_chunks_workspace_id_idx": {
+ "name": "document_chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_chunks_document_id_documents_id_fk": {
+ "name": "document_chunks_document_id_documents_id_fk",
+ "tableFrom": "document_chunks",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_chunks_chunk_id_chunks_id_fk": {
+ "name": "document_chunks_chunk_id_chunks_id_fk",
+ "tableFrom": "document_chunks",
+ "tableTo": "chunks",
+ "columnsFrom": ["chunk_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_chunks_user_id_users_id_fk": {
+ "name": "document_chunks_user_id_users_id_fk",
+ "tableFrom": "document_chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_chunks_workspace_id_workspaces_id_fk": {
+ "name": "document_chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "document_chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "document_chunks_document_id_chunk_id_pk": {
+ "name": "document_chunks_document_id_chunk_id_pk",
+ "columns": ["document_id", "chunk_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.embeddings": {
+ "name": "embeddings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "chunk_id": {
+ "name": "chunk_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "embeddings": {
+ "name": "embeddings",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "embeddings_client_id_user_id_unique": {
+ "name": "embeddings_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "embeddings_chunk_id_idx": {
+ "name": "embeddings_chunk_id_idx",
+ "columns": [
+ {
+ "expression": "chunk_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "embeddings_user_id_idx": {
+ "name": "embeddings_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "embeddings_workspace_id_idx": {
+ "name": "embeddings_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "embeddings_chunk_id_chunks_id_fk": {
+ "name": "embeddings_chunk_id_chunks_id_fk",
+ "tableFrom": "embeddings",
+ "tableTo": "chunks",
+ "columnsFrom": ["chunk_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "embeddings_user_id_users_id_fk": {
+ "name": "embeddings_user_id_users_id_fk",
+ "tableFrom": "embeddings",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "embeddings_workspace_id_workspaces_id_fk": {
+ "name": "embeddings_workspace_id_workspaces_id_fk",
+ "tableFrom": "embeddings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "embeddings_chunk_id_unique": {
+ "name": "embeddings_chunk_id_unique",
+ "nullsNotDistinct": false,
+ "columns": ["chunk_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.unstructured_chunks": {
+ "name": "unstructured_chunks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "index": {
+ "name": "index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "varchar",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "composite_id": {
+ "name": "composite_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "varchar",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "unstructured_chunks_client_id_user_id_unique": {
+ "name": "unstructured_chunks_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unstructured_chunks_user_id_idx": {
+ "name": "unstructured_chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unstructured_chunks_composite_id_idx": {
+ "name": "unstructured_chunks_composite_id_idx",
+ "columns": [
+ {
+ "expression": "composite_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unstructured_chunks_file_id_idx": {
+ "name": "unstructured_chunks_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "unstructured_chunks_workspace_id_idx": {
+ "name": "unstructured_chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "unstructured_chunks_composite_id_chunks_id_fk": {
+ "name": "unstructured_chunks_composite_id_chunks_id_fk",
+ "tableFrom": "unstructured_chunks",
+ "tableTo": "chunks",
+ "columnsFrom": ["composite_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "unstructured_chunks_user_id_users_id_fk": {
+ "name": "unstructured_chunks_user_id_users_id_fk",
+ "tableFrom": "unstructured_chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "unstructured_chunks_workspace_id_workspaces_id_fk": {
+ "name": "unstructured_chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "unstructured_chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "unstructured_chunks_file_id_files_id_fk": {
+ "name": "unstructured_chunks_file_id_files_id_fk",
+ "tableFrom": "unstructured_chunks",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rag_eval_dataset_records": {
+ "name": "rag_eval_dataset_records",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "dataset_id": {
+ "name": "dataset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ideal": {
+ "name": "ideal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "question": {
+ "name": "question",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_files": {
+ "name": "reference_files",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rag_eval_dataset_records_user_id_idx": {
+ "name": "rag_eval_dataset_records_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rag_eval_dataset_records_workspace_id_idx": {
+ "name": "rag_eval_dataset_records_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk": {
+ "name": "rag_eval_dataset_records_dataset_id_rag_eval_datasets_id_fk",
+ "tableFrom": "rag_eval_dataset_records",
+ "tableTo": "rag_eval_datasets",
+ "columnsFrom": ["dataset_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_dataset_records_user_id_users_id_fk": {
+ "name": "rag_eval_dataset_records_user_id_users_id_fk",
+ "tableFrom": "rag_eval_dataset_records",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_dataset_records_workspace_id_workspaces_id_fk": {
+ "name": "rag_eval_dataset_records_workspace_id_workspaces_id_fk",
+ "tableFrom": "rag_eval_dataset_records",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rag_eval_datasets": {
+ "name": "rag_eval_datasets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rag_eval_datasets_user_id_idx": {
+ "name": "rag_eval_datasets_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rag_eval_datasets_workspace_id_idx": {
+ "name": "rag_eval_datasets_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "rag_eval_datasets_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "rag_eval_datasets",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_datasets_user_id_users_id_fk": {
+ "name": "rag_eval_datasets_user_id_users_id_fk",
+ "tableFrom": "rag_eval_datasets",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_datasets_workspace_id_workspaces_id_fk": {
+ "name": "rag_eval_datasets_workspace_id_workspaces_id_fk",
+ "tableFrom": "rag_eval_datasets",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rag_eval_evaluations": {
+ "name": "rag_eval_evaluations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "eval_records_url": {
+ "name": "eval_records_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dataset_id": {
+ "name": "dataset_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "knowledge_base_id": {
+ "name": "knowledge_base_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_model": {
+ "name": "language_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "embedding_model": {
+ "name": "embedding_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rag_eval_evaluations_user_id_idx": {
+ "name": "rag_eval_evaluations_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rag_eval_evaluations_workspace_id_idx": {
+ "name": "rag_eval_evaluations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk": {
+ "name": "rag_eval_evaluations_dataset_id_rag_eval_datasets_id_fk",
+ "tableFrom": "rag_eval_evaluations",
+ "tableTo": "rag_eval_datasets",
+ "columnsFrom": ["dataset_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk": {
+ "name": "rag_eval_evaluations_knowledge_base_id_knowledge_bases_id_fk",
+ "tableFrom": "rag_eval_evaluations",
+ "tableTo": "knowledge_bases",
+ "columnsFrom": ["knowledge_base_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluations_user_id_users_id_fk": {
+ "name": "rag_eval_evaluations_user_id_users_id_fk",
+ "tableFrom": "rag_eval_evaluations",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluations_workspace_id_workspaces_id_fk": {
+ "name": "rag_eval_evaluations_workspace_id_workspaces_id_fk",
+ "tableFrom": "rag_eval_evaluations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rag_eval_evaluation_records": {
+ "name": "rag_eval_evaluation_records",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "question": {
+ "name": "question",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "answer": {
+ "name": "answer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context": {
+ "name": "context",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ideal": {
+ "name": "ideal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_model": {
+ "name": "language_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "embedding_model": {
+ "name": "embedding_model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "question_embedding_id": {
+ "name": "question_embedding_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dataset_record_id": {
+ "name": "dataset_record_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "evaluation_id": {
+ "name": "evaluation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rag_eval_evaluation_records_user_id_idx": {
+ "name": "rag_eval_evaluation_records_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rag_eval_evaluation_records_workspace_id_idx": {
+ "name": "rag_eval_evaluation_records_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk": {
+ "name": "rag_eval_evaluation_records_question_embedding_id_embeddings_id_fk",
+ "tableFrom": "rag_eval_evaluation_records",
+ "tableTo": "embeddings",
+ "columnsFrom": ["question_embedding_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk": {
+ "name": "rag_eval_evaluation_records_dataset_record_id_rag_eval_dataset_records_id_fk",
+ "tableFrom": "rag_eval_evaluation_records",
+ "tableTo": "rag_eval_dataset_records",
+ "columnsFrom": ["dataset_record_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk": {
+ "name": "rag_eval_evaluation_records_evaluation_id_rag_eval_evaluations_id_fk",
+ "tableFrom": "rag_eval_evaluation_records",
+ "tableTo": "rag_eval_evaluations",
+ "columnsFrom": ["evaluation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluation_records_user_id_users_id_fk": {
+ "name": "rag_eval_evaluation_records_user_id_users_id_fk",
+ "tableFrom": "rag_eval_evaluation_records",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rag_eval_evaluation_records_workspace_id_workspaces_id_fk": {
+ "name": "rag_eval_evaluation_records_workspace_id_workspaces_id_fk",
+ "tableFrom": "rag_eval_evaluation_records",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rbac_permissions": {
+ "name": "rbac_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "code": {
+ "name": "code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "category": {
+ "name": "category",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "rbac_permissions_code_unique": {
+ "name": "rbac_permissions_code_unique",
+ "nullsNotDistinct": false,
+ "columns": ["code"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rbac_role_permissions": {
+ "name": "rbac_role_permissions",
+ "schema": "",
+ "columns": {
+ "role_id": {
+ "name": "role_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permission_id": {
+ "name": "permission_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rbac_role_permissions_role_id_idx": {
+ "name": "rbac_role_permissions_role_id_idx",
+ "columns": [
+ {
+ "expression": "role_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rbac_role_permissions_permission_id_idx": {
+ "name": "rbac_role_permissions_permission_id_idx",
+ "columns": [
+ {
+ "expression": "permission_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rbac_role_permissions_role_id_rbac_roles_id_fk": {
+ "name": "rbac_role_permissions_role_id_rbac_roles_id_fk",
+ "tableFrom": "rbac_role_permissions",
+ "tableTo": "rbac_roles",
+ "columnsFrom": ["role_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rbac_role_permissions_permission_id_rbac_permissions_id_fk": {
+ "name": "rbac_role_permissions_permission_id_rbac_permissions_id_fk",
+ "tableFrom": "rbac_role_permissions",
+ "tableTo": "rbac_permissions",
+ "columnsFrom": ["permission_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "rbac_role_permissions_role_id_permission_id_pk": {
+ "name": "rbac_role_permissions_role_id_permission_id_pk",
+ "columns": ["role_id", "permission_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rbac_roles": {
+ "name": "rbac_roles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_system": {
+ "name": "is_system",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "rbac_roles_workspace_id_idx": {
+ "name": "rbac_roles_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rbac_roles_name_workspace_unique": {
+ "name": "rbac_roles_name_workspace_unique",
+ "columns": [
+ {
+ "expression": "name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "COALESCE(\"workspace_id\", '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rbac_roles_workspace_id_workspaces_id_fk": {
+ "name": "rbac_roles_workspace_id_workspaces_id_fk",
+ "tableFrom": "rbac_roles",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.rbac_user_roles": {
+ "name": "rbac_user_roles",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "rbac_user_roles_user_role_scope_unique": {
+ "name": "rbac_user_roles_user_role_scope_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "role_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "COALESCE(\"workspace_id\", '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rbac_user_roles_user_id_idx": {
+ "name": "rbac_user_roles_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rbac_user_roles_role_id_idx": {
+ "name": "rbac_user_roles_role_id_idx",
+ "columns": [
+ {
+ "expression": "role_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "rbac_user_roles_workspace_id_idx": {
+ "name": "rbac_user_roles_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "rbac_user_roles_user_id_users_id_fk": {
+ "name": "rbac_user_roles_user_id_users_id_fk",
+ "tableFrom": "rbac_user_roles",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rbac_user_roles_role_id_rbac_roles_id_fk": {
+ "name": "rbac_user_roles_role_id_rbac_roles_id_fk",
+ "tableFrom": "rbac_user_roles",
+ "tableTo": "rbac_roles",
+ "columnsFrom": ["role_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "rbac_user_roles_workspace_id_workspaces_id_fk": {
+ "name": "rbac_user_roles_workspace_id_workspaces_id_fk",
+ "tableFrom": "rbac_user_roles",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agents_to_sessions": {
+ "name": "agents_to_sessions",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "agents_to_sessions_session_id_idx": {
+ "name": "agents_to_sessions_session_id_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_to_sessions_agent_id_idx": {
+ "name": "agents_to_sessions_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_to_sessions_user_id_idx": {
+ "name": "agents_to_sessions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agents_to_sessions_workspace_id_idx": {
+ "name": "agents_to_sessions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agents_to_sessions_agent_id_agents_id_fk": {
+ "name": "agents_to_sessions_agent_id_agents_id_fk",
+ "tableFrom": "agents_to_sessions",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_to_sessions_session_id_sessions_id_fk": {
+ "name": "agents_to_sessions_session_id_sessions_id_fk",
+ "tableFrom": "agents_to_sessions",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_to_sessions_user_id_users_id_fk": {
+ "name": "agents_to_sessions_user_id_users_id_fk",
+ "tableFrom": "agents_to_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agents_to_sessions_workspace_id_workspaces_id_fk": {
+ "name": "agents_to_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "agents_to_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agents_to_sessions_agent_id_session_id_pk": {
+ "name": "agents_to_sessions_agent_id_session_id_pk",
+ "columns": ["agent_id", "session_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.file_chunks": {
+ "name": "file_chunks",
+ "schema": "",
+ "columns": {
+ "file_id": {
+ "name": "file_id",
+ "type": "varchar",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "chunk_id": {
+ "name": "chunk_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "file_chunks_user_id_idx": {
+ "name": "file_chunks_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_chunks_workspace_id_idx": {
+ "name": "file_chunks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_chunks_file_id_idx": {
+ "name": "file_chunks_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "file_chunks_chunk_id_idx": {
+ "name": "file_chunks_chunk_id_idx",
+ "columns": [
+ {
+ "expression": "chunk_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "file_chunks_file_id_files_id_fk": {
+ "name": "file_chunks_file_id_files_id_fk",
+ "tableFrom": "file_chunks",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "file_chunks_chunk_id_chunks_id_fk": {
+ "name": "file_chunks_chunk_id_chunks_id_fk",
+ "tableFrom": "file_chunks",
+ "tableTo": "chunks",
+ "columnsFrom": ["chunk_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "file_chunks_user_id_users_id_fk": {
+ "name": "file_chunks_user_id_users_id_fk",
+ "tableFrom": "file_chunks",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "file_chunks_workspace_id_workspaces_id_fk": {
+ "name": "file_chunks_workspace_id_workspaces_id_fk",
+ "tableFrom": "file_chunks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "file_chunks_file_id_chunk_id_pk": {
+ "name": "file_chunks_file_id_chunk_id_pk",
+ "columns": ["file_id", "chunk_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.files_to_sessions": {
+ "name": "files_to_sessions",
+ "schema": "",
+ "columns": {
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "files_to_sessions_user_id_idx": {
+ "name": "files_to_sessions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_to_sessions_workspace_id_idx": {
+ "name": "files_to_sessions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_to_sessions_file_id_idx": {
+ "name": "files_to_sessions_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "files_to_sessions_session_id_idx": {
+ "name": "files_to_sessions_session_id_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "files_to_sessions_file_id_files_id_fk": {
+ "name": "files_to_sessions_file_id_files_id_fk",
+ "tableFrom": "files_to_sessions",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_to_sessions_session_id_sessions_id_fk": {
+ "name": "files_to_sessions_session_id_sessions_id_fk",
+ "tableFrom": "files_to_sessions",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_to_sessions_user_id_users_id_fk": {
+ "name": "files_to_sessions_user_id_users_id_fk",
+ "tableFrom": "files_to_sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "files_to_sessions_workspace_id_workspaces_id_fk": {
+ "name": "files_to_sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "files_to_sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "files_to_sessions_file_id_session_id_pk": {
+ "name": "files_to_sessions_file_id_session_id_pk",
+ "columns": ["file_id", "session_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.resource_permissions": {
+ "name": "resource_permissions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_level": {
+ "name": "access_level",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "resource_permissions_workspace_resource_unique": {
+ "name": "resource_permissions_workspace_resource_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"resource_permissions\".\"user_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_workspace_resource_user_id_unique": {
+ "name": "resource_permissions_workspace_resource_user_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"resource_permissions\".\"user_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_resource_idx": {
+ "name": "resource_permissions_resource_idx",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_workspace_idx": {
+ "name": "resource_permissions_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_user_id_idx": {
+ "name": "resource_permissions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_created_by_idx": {
+ "name": "resource_permissions_created_by_idx",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_permissions_workspace_user_idx": {
+ "name": "resource_permissions_workspace_user_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "resource_permissions_workspace_id_workspaces_id_fk": {
+ "name": "resource_permissions_workspace_id_workspaces_id_fk",
+ "tableFrom": "resource_permissions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "resource_permissions_user_id_users_id_fk": {
+ "name": "resource_permissions_user_id_users_id_fk",
+ "tableFrom": "resource_permissions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "resource_permissions_created_by_users_id_fk": {
+ "name": "resource_permissions_created_by_users_id_fk",
+ "tableFrom": "resource_permissions",
+ "tableTo": "users",
+ "columnsFrom": ["created_by"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.resource_transfer_requests": {
+ "name": "resource_transfer_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initiator_id": {
+ "name": "initiator_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "recipient_id": {
+ "name": "recipient_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_owner_id": {
+ "name": "previous_owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "resource_transfer_requests_pending_resource_unique": {
+ "name": "resource_transfer_requests_pending_resource_unique",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"resource_transfer_requests\".\"status\" = 'pending' AND \"resource_transfer_requests\".\"recipient_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_transfer_requests_recipient_idx": {
+ "name": "resource_transfer_requests_recipient_idx",
+ "columns": [
+ {
+ "expression": "recipient_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "resource_transfer_requests_workspace_idx": {
+ "name": "resource_transfer_requests_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "resource_transfer_requests_workspace_id_workspaces_id_fk": {
+ "name": "resource_transfer_requests_workspace_id_workspaces_id_fk",
+ "tableFrom": "resource_transfer_requests",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "resource_transfer_requests_initiator_id_users_id_fk": {
+ "name": "resource_transfer_requests_initiator_id_users_id_fk",
+ "tableFrom": "resource_transfer_requests",
+ "tableTo": "users",
+ "columnsFrom": ["initiator_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "resource_transfer_requests_recipient_id_users_id_fk": {
+ "name": "resource_transfer_requests_recipient_id_users_id_fk",
+ "tableFrom": "resource_transfer_requests",
+ "tableTo": "users",
+ "columnsFrom": ["recipient_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "resource_transfer_requests_previous_owner_id_users_id_fk": {
+ "name": "resource_transfer_requests_previous_owner_id_users_id_fk",
+ "tableFrom": "resource_transfer_requests",
+ "tableTo": "users",
+ "columnsFrom": ["previous_owner_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scm_change_requests": {
+ "name": "scm_change_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repo_external_id": {
+ "name": "repo_external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_external_id": {
+ "name": "author_external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_external_login": {
+ "name": "author_external_login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "head_ref": {
+ "name": "head_ref",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "base_ref": {
+ "name": "base_ref",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_draft": {
+ "name": "is_draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "merged_at": {
+ "name": "merged_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "closed_at": {
+ "name": "closed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merged_by_external_id": {
+ "name": "merged_by_external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ci_status": {
+ "name": "ci_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ci_head_sha": {
+ "name": "ci_head_sha",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "checks": {
+ "name": "checks",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_decision": {
+ "name": "review_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "merge_state_status": {
+ "name": "merge_state_status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_id": {
+ "name": "acceptance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "work_id": {
+ "name": "work_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wake_count": {
+ "name": "wake_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "last_wake_at": {
+ "name": "last_wake_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_event_at": {
+ "name": "last_event_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_event_kind": {
+ "name": "last_event_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scm_change_requests_provider_repo_number_unique": {
+ "name": "scm_change_requests_provider_repo_number_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repo_full_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_acceptance_id_idx": {
+ "name": "scm_change_requests_acceptance_id_idx",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_topic_id_idx": {
+ "name": "scm_change_requests_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_work_id_idx": {
+ "name": "scm_change_requests_work_id_idx",
+ "columns": [
+ {
+ "expression": "work_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_installation_id_idx": {
+ "name": "scm_change_requests_installation_id_idx",
+ "columns": [
+ {
+ "expression": "installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_user_updated_at_idx": {
+ "name": "scm_change_requests_user_updated_at_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_workspace_id_idx": {
+ "name": "scm_change_requests_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_change_requests_head_sha_idx": {
+ "name": "scm_change_requests_head_sha_idx",
+ "columns": [
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scm_change_requests_user_id_users_id_fk": {
+ "name": "scm_change_requests_user_id_users_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_workspace_id_workspaces_id_fk": {
+ "name": "scm_change_requests_workspace_id_workspaces_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_installation_id_scm_installations_id_fk": {
+ "name": "scm_change_requests_installation_id_scm_installations_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "scm_installations",
+ "columnsFrom": ["installation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_acceptance_id_acceptances_id_fk": {
+ "name": "scm_change_requests_acceptance_id_acceptances_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "acceptances",
+ "columnsFrom": ["acceptance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_work_id_works_id_fk": {
+ "name": "scm_change_requests_work_id_works_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "works",
+ "columnsFrom": ["work_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_topic_id_topics_id_fk": {
+ "name": "scm_change_requests_topic_id_topics_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "scm_change_requests_task_id_tasks_id_fk": {
+ "name": "scm_change_requests_task_id_tasks_id_fk",
+ "tableFrom": "scm_change_requests",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scm_identities": {
+ "name": "scm_identities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_user_id": {
+ "name": "external_user_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_login": {
+ "name": "external_login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_expires_at": {
+ "name": "token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scm_identities_provider_external_user_unique": {
+ "name": "scm_identities_provider_external_user_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_identities_provider_user_unique": {
+ "name": "scm_identities_provider_user_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_identities_token_expires_at_idx": {
+ "name": "scm_identities_token_expires_at_idx",
+ "columns": [
+ {
+ "expression": "token_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scm_identities_user_id_users_id_fk": {
+ "name": "scm_identities_user_id_users_id_fk",
+ "tableFrom": "scm_identities",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scm_installations": {
+ "name": "scm_installations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_login": {
+ "name": "account_login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_external_id": {
+ "name": "account_external_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_type": {
+ "name": "account_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository_selection": {
+ "name": "repository_selection",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repositories": {
+ "name": "repositories",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "installed_by_external_user_id": {
+ "name": "installed_by_external_user_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installed_by_external_login": {
+ "name": "installed_by_external_login",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suspended_at": {
+ "name": "suspended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scm_installations_provider_installation_unique": {
+ "name": "scm_installations_provider_installation_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "installation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_installations_user_id_idx": {
+ "name": "scm_installations_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_installations_workspace_id_idx": {
+ "name": "scm_installations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_installations_provider_account_idx": {
+ "name": "scm_installations_provider_account_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "account_login",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scm_installations_user_id_users_id_fk": {
+ "name": "scm_installations_user_id_users_id_fk",
+ "tableFrom": "scm_installations",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scm_installations_workspace_id_workspaces_id_fk": {
+ "name": "scm_installations_workspace_id_workspaces_id_fk",
+ "tableFrom": "scm_installations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scm_webhook_deliveries": {
+ "name": "scm_webhook_deliveries",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delivery_id": {
+ "name": "delivery_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event": {
+ "name": "event",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "installation_id": {
+ "name": "installation_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repo_full_name": {
+ "name": "repo_full_name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "received_at": {
+ "name": "received_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "scm_webhook_deliveries_provider_delivery_unique": {
+ "name": "scm_webhook_deliveries_provider_delivery_unique",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "delivery_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scm_webhook_deliveries_received_at_idx": {
+ "name": "scm_webhook_deliveries_received_at_idx",
+ "columns": [
+ {
+ "expression": "received_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session_groups": {
+ "name": "session_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sort": {
+ "name": "sort",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "session_groups_client_id_user_id_unique": {
+ "name": "session_groups_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "session_groups_user_id_idx": {
+ "name": "session_groups_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "session_groups_workspace_id_idx": {
+ "name": "session_groups_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "session_groups_workspace_visibility_idx": {
+ "name": "session_groups_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_groups_user_id_users_id_fk": {
+ "name": "session_groups_user_id_users_id_fk",
+ "tableFrom": "session_groups",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "session_groups_workspace_id_workspaces_id_fk": {
+ "name": "session_groups_workspace_id_workspaces_id_fk",
+ "tableFrom": "session_groups",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sessions": {
+ "name": "sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "background_color": {
+ "name": "background_color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'agent'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned": {
+ "name": "pinned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "slug_user_id_unique": {
+ "name": "slug_user_id_unique",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"sessions\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_client_id_user_id_unique": {
+ "name": "sessions_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_user_id_idx": {
+ "name": "sessions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_id_user_id_idx": {
+ "name": "sessions_id_user_id_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_user_id_updated_at_idx": {
+ "name": "sessions_user_id_updated_at_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_group_id_idx": {
+ "name": "sessions_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_workspace_id_idx": {
+ "name": "sessions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "sessions_slug_workspace_id_unique": {
+ "name": "sessions_slug_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"sessions\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sessions_user_id_users_id_fk": {
+ "name": "sessions_user_id_users_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "sessions_group_id_session_groups_id_fk": {
+ "name": "sessions_group_id_session_groups_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "session_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "sessions_workspace_id_workspaces_id_fk": {
+ "name": "sessions_workspace_id_workspaces_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.signals": {
+ "name": "signals",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "occurred_at": {
+ "name": "occurred_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "processed_at": {
+ "name": "processed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "signals_source_external_id_unique": {
+ "name": "signals_source_external_id_unique",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "signals_status_created_at_idx": {
+ "name": "signals_status_created_at_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "signals_account_created_at_idx": {
+ "name": "signals_account_created_at_idx",
+ "columns": [
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "signals_user_id_idx": {
+ "name": "signals_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "signals_user_id_users_id_fk": {
+ "name": "signals_user_id_users_id_fk",
+ "tableFrom": "signals",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "signals_workspace_id_workspaces_id_fk": {
+ "name": "signals_workspace_id_workspaces_id_fk",
+ "tableFrom": "signals",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "signals_account_id_agent_accounts_id_fk": {
+ "name": "signals_account_id_agent_accounts_id_fk",
+ "tableFrom": "signals",
+ "tableTo": "agent_accounts",
+ "columnsFrom": ["account_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "signals_agent_id_agents_id_fk": {
+ "name": "signals_agent_id_agents_id_fk",
+ "tableFrom": "signals",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.system_bot_providers": {
+ "name": "system_bot_providers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "platform": {
+ "name": "platform",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "credentials": {
+ "name": "credentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "application_id": {
+ "name": "application_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "connection_mode": {
+ "name": "connection_mode",
+ "type": "varchar(20)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "system_bot_providers_platform_unique": {
+ "name": "system_bot_providers_platform_unique",
+ "columns": [
+ {
+ "expression": "platform",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.briefs": {
+ "name": "briefs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cron_job_id": {
+ "name": "cron_job_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'info'"
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "artifacts": {
+ "name": "artifacts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actions": {
+ "name": "actions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_action": {
+ "name": "resolved_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_comment": {
+ "name": "resolved_comment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "read_at": {
+ "name": "read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "briefs_user_id_idx": {
+ "name": "briefs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_task_id_idx": {
+ "name": "briefs_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_cron_job_id_idx": {
+ "name": "briefs_cron_job_id_idx",
+ "columns": [
+ {
+ "expression": "cron_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_agent_id_idx": {
+ "name": "briefs_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_type_idx": {
+ "name": "briefs_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_priority_idx": {
+ "name": "briefs_priority_idx",
+ "columns": [
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_unresolved_idx": {
+ "name": "briefs_unresolved_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resolved_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_trigger_idx": {
+ "name": "briefs_trigger_idx",
+ "columns": [
+ {
+ "expression": "trigger",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "briefs_workspace_id_idx": {
+ "name": "briefs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "briefs_user_id_users_id_fk": {
+ "name": "briefs_user_id_users_id_fk",
+ "tableFrom": "briefs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "briefs_workspace_id_workspaces_id_fk": {
+ "name": "briefs_workspace_id_workspaces_id_fk",
+ "tableFrom": "briefs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "briefs_task_id_tasks_id_fk": {
+ "name": "briefs_task_id_tasks_id_fk",
+ "tableFrom": "briefs",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "briefs_cron_job_id_agent_cron_jobs_id_fk": {
+ "name": "briefs_cron_job_id_agent_cron_jobs_id_fk",
+ "tableFrom": "briefs",
+ "tableTo": "agent_cron_jobs",
+ "columnsFrom": ["cron_job_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_activities": {
+ "name": "task_activities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_agent_id": {
+ "name": "actor_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_activities_task_id_idx": {
+ "name": "task_activities_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_activities_user_id_idx": {
+ "name": "task_activities_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_activities_workspace_id_idx": {
+ "name": "task_activities_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_activities_workspace_visibility_idx": {
+ "name": "task_activities_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_activities_task_id_tasks_id_fk": {
+ "name": "task_activities_task_id_tasks_id_fk",
+ "tableFrom": "task_activities",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_activities_user_id_users_id_fk": {
+ "name": "task_activities_user_id_users_id_fk",
+ "tableFrom": "task_activities",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_activities_workspace_id_workspaces_id_fk": {
+ "name": "task_activities_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_activities",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_activities_actor_user_id_users_id_fk": {
+ "name": "task_activities_actor_user_id_users_id_fk",
+ "tableFrom": "task_activities",
+ "tableTo": "users",
+ "columnsFrom": ["actor_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "task_activities_actor_agent_id_agents_id_fk": {
+ "name": "task_activities_actor_agent_id_agents_id_fk",
+ "tableFrom": "task_activities",
+ "tableTo": "agents",
+ "columnsFrom": ["actor_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_comments": {
+ "name": "task_comments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_agent_id": {
+ "name": "author_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "brief_id": {
+ "name": "brief_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_comments_task_id_idx": {
+ "name": "task_comments_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_user_id_idx": {
+ "name": "task_comments_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_author_user_id_idx": {
+ "name": "task_comments_author_user_id_idx",
+ "columns": [
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_agent_id_idx": {
+ "name": "task_comments_agent_id_idx",
+ "columns": [
+ {
+ "expression": "author_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_brief_id_idx": {
+ "name": "task_comments_brief_id_idx",
+ "columns": [
+ {
+ "expression": "brief_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_topic_id_idx": {
+ "name": "task_comments_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_workspace_id_idx": {
+ "name": "task_comments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_comments_workspace_visibility_idx": {
+ "name": "task_comments_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_comments_task_id_tasks_id_fk": {
+ "name": "task_comments_task_id_tasks_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_comments_user_id_users_id_fk": {
+ "name": "task_comments_user_id_users_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_comments_workspace_id_workspaces_id_fk": {
+ "name": "task_comments_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_comments_author_user_id_users_id_fk": {
+ "name": "task_comments_author_user_id_users_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "users",
+ "columnsFrom": ["author_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "task_comments_author_agent_id_agents_id_fk": {
+ "name": "task_comments_author_agent_id_agents_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "agents",
+ "columnsFrom": ["author_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "task_comments_brief_id_briefs_id_fk": {
+ "name": "task_comments_brief_id_briefs_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "briefs",
+ "columnsFrom": ["brief_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "task_comments_topic_id_topics_id_fk": {
+ "name": "task_comments_topic_id_topics_id_fk",
+ "tableFrom": "task_comments",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_dependencies": {
+ "name": "task_dependencies",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "depends_on_id": {
+ "name": "depends_on_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'blocks'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "condition": {
+ "name": "condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_deps_unique_idx": {
+ "name": "task_deps_unique_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "depends_on_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_deps_task_id_idx": {
+ "name": "task_deps_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_deps_depends_on_id_idx": {
+ "name": "task_deps_depends_on_id_idx",
+ "columns": [
+ {
+ "expression": "depends_on_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_deps_user_id_idx": {
+ "name": "task_deps_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_dependencies_workspace_id_idx": {
+ "name": "task_dependencies_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_deps_workspace_visibility_idx": {
+ "name": "task_deps_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_dependencies_task_id_tasks_id_fk": {
+ "name": "task_dependencies_task_id_tasks_id_fk",
+ "tableFrom": "task_dependencies",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_dependencies_depends_on_id_tasks_id_fk": {
+ "name": "task_dependencies_depends_on_id_tasks_id_fk",
+ "tableFrom": "task_dependencies",
+ "tableTo": "tasks",
+ "columnsFrom": ["depends_on_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_dependencies_user_id_users_id_fk": {
+ "name": "task_dependencies_user_id_users_id_fk",
+ "tableFrom": "task_dependencies",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_dependencies_workspace_id_workspaces_id_fk": {
+ "name": "task_dependencies_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_dependencies",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_documents": {
+ "name": "task_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned_by": {
+ "name": "pinned_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'agent'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_docs_unique_idx": {
+ "name": "task_docs_unique_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_docs_task_id_idx": {
+ "name": "task_docs_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_docs_document_id_idx": {
+ "name": "task_docs_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_docs_user_id_idx": {
+ "name": "task_docs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_documents_workspace_id_idx": {
+ "name": "task_documents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_docs_workspace_visibility_idx": {
+ "name": "task_docs_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_documents_task_id_tasks_id_fk": {
+ "name": "task_documents_task_id_tasks_id_fk",
+ "tableFrom": "task_documents",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_documents_document_id_documents_id_fk": {
+ "name": "task_documents_document_id_documents_id_fk",
+ "tableFrom": "task_documents",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_documents_user_id_users_id_fk": {
+ "name": "task_documents_user_id_users_id_fk",
+ "tableFrom": "task_documents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_documents_workspace_id_workspaces_id_fk": {
+ "name": "task_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.task_topics": {
+ "name": "task_topics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "task_id": {
+ "name": "task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seq": {
+ "name": "seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "handoff": {
+ "name": "handoff",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_passed": {
+ "name": "review_passed",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_score": {
+ "name": "review_score",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_scores": {
+ "name": "review_scores",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "review_iteration": {
+ "name": "review_iteration",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_at": {
+ "name": "reviewed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "task_topics_unique_idx": {
+ "name": "task_topics_unique_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_task_id_idx": {
+ "name": "task_topics_task_id_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_topic_id_idx": {
+ "name": "task_topics_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_user_id_idx": {
+ "name": "task_topics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_status_idx": {
+ "name": "task_topics_status_idx",
+ "columns": [
+ {
+ "expression": "task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_workspace_id_idx": {
+ "name": "task_topics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "task_topics_workspace_visibility_idx": {
+ "name": "task_topics_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "task_topics_task_id_tasks_id_fk": {
+ "name": "task_topics_task_id_tasks_id_fk",
+ "tableFrom": "task_topics",
+ "tableTo": "tasks",
+ "columnsFrom": ["task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_topics_topic_id_topics_id_fk": {
+ "name": "task_topics_topic_id_topics_id_fk",
+ "tableFrom": "task_topics",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_topics_user_id_users_id_fk": {
+ "name": "task_topics_user_id_users_id_fk",
+ "tableFrom": "task_topics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "task_topics_workspace_id_workspaces_id_fk": {
+ "name": "task_topics_workspace_id_workspaces_id_fk",
+ "tableFrom": "task_topics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.tasks": {
+ "name": "tasks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "seq": {
+ "name": "seq",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_agent_id": {
+ "name": "created_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_agent_id": {
+ "name": "assignee_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_task_id": {
+ "name": "parent_task_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instruction": {
+ "name": "instruction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'backlog'"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "automation_mode": {
+ "name": "automation_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heartbeat_interval": {
+ "name": "heartbeat_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "heartbeat_timeout": {
+ "name": "heartbeat_timeout",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_heartbeat_at": {
+ "name": "last_heartbeat_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_pattern": {
+ "name": "schedule_pattern",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_timezone": {
+ "name": "schedule_timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'UTC'"
+ },
+ "total_topics": {
+ "name": "total_topics",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "max_topics": {
+ "name": "max_topics",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_topic_id": {
+ "name": "current_topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context": {
+ "name": "context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "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
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "tasks_identifier_idx": {
+ "name": "tasks_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"tasks\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_created_by_user_id_idx": {
+ "name": "tasks_created_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_created_by_agent_id_idx": {
+ "name": "tasks_created_by_agent_id_idx",
+ "columns": [
+ {
+ "expression": "created_by_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_assignee_user_id_idx": {
+ "name": "tasks_assignee_user_id_idx",
+ "columns": [
+ {
+ "expression": "assignee_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_assignee_agent_id_idx": {
+ "name": "tasks_assignee_agent_id_idx",
+ "columns": [
+ {
+ "expression": "assignee_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_parent_task_id_idx": {
+ "name": "tasks_parent_task_id_idx",
+ "columns": [
+ {
+ "expression": "parent_task_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_status_idx": {
+ "name": "tasks_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_priority_idx": {
+ "name": "tasks_priority_idx",
+ "columns": [
+ {
+ "expression": "priority",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_automation_mode_idx": {
+ "name": "tasks_automation_mode_idx",
+ "columns": [
+ {
+ "expression": "automation_mode",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_heartbeat_idx": {
+ "name": "tasks_heartbeat_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "last_heartbeat_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_workspace_id_idx": {
+ "name": "tasks_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_project_id_status_idx": {
+ "name": "tasks_project_id_status_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_workspace_visibility_idx": {
+ "name": "tasks_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "tasks_identifier_workspace_id_unique": {
+ "name": "tasks_identifier_workspace_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"tasks\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "tasks_created_by_user_id_users_id_fk": {
+ "name": "tasks_created_by_user_id_users_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "users",
+ "columnsFrom": ["created_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "tasks_workspace_id_workspaces_id_fk": {
+ "name": "tasks_workspace_id_workspaces_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "tasks_project_id_projects_id_fk": {
+ "name": "tasks_project_id_projects_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "tasks_created_by_agent_id_agents_id_fk": {
+ "name": "tasks_created_by_agent_id_agents_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "agents",
+ "columnsFrom": ["created_by_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "tasks_assignee_user_id_users_id_fk": {
+ "name": "tasks_assignee_user_id_users_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "users",
+ "columnsFrom": ["assignee_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "tasks_assignee_agent_id_agents_id_fk": {
+ "name": "tasks_assignee_agent_id_agents_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "agents",
+ "columnsFrom": ["assignee_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "tasks_current_topic_id_topics_id_fk": {
+ "name": "tasks_current_topic_id_topics_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "topics",
+ "columnsFrom": ["current_topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "tasks_parent_task_id_tasks_id_fk": {
+ "name": "tasks_parent_task_id_tasks_id_fk",
+ "tableFrom": "tasks",
+ "tableTo": "tasks",
+ "columnsFrom": ["parent_task_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.threads": {
+ "name": "threads",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_message_id": {
+ "name": "source_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_thread_id": {
+ "name": "parent_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_active_at": {
+ "name": "last_active_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "now()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "threads_client_id_user_id_unique": {
+ "name": "threads_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_user_id_idx": {
+ "name": "threads_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_topic_id_idx": {
+ "name": "threads_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_type_idx": {
+ "name": "threads_type_idx",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_agent_id_idx": {
+ "name": "threads_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_group_id_idx": {
+ "name": "threads_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_parent_thread_id_idx": {
+ "name": "threads_parent_thread_id_idx",
+ "columns": [
+ {
+ "expression": "parent_thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "threads_workspace_id_idx": {
+ "name": "threads_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "threads_topic_id_topics_id_fk": {
+ "name": "threads_topic_id_topics_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "threads_parent_thread_id_threads_id_fk": {
+ "name": "threads_parent_thread_id_threads_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "threads",
+ "columnsFrom": ["parent_thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "threads_agent_id_agents_id_fk": {
+ "name": "threads_agent_id_agents_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "threads_group_id_chat_groups_id_fk": {
+ "name": "threads_group_id_chat_groups_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "threads_user_id_users_id_fk": {
+ "name": "threads_user_id_users_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "threads_workspace_id_workspaces_id_fk": {
+ "name": "threads_workspace_id_workspaces_id_fk",
+ "tableFrom": "threads",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.topic_documents": {
+ "name": "topic_documents",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "topic_documents_user_id_idx": {
+ "name": "topic_documents_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_documents_topic_id_idx": {
+ "name": "topic_documents_topic_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_documents_document_id_idx": {
+ "name": "topic_documents_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_documents_workspace_id_idx": {
+ "name": "topic_documents_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topic_documents_document_id_documents_id_fk": {
+ "name": "topic_documents_document_id_documents_id_fk",
+ "tableFrom": "topic_documents",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_documents_topic_id_topics_id_fk": {
+ "name": "topic_documents_topic_id_topics_id_fk",
+ "tableFrom": "topic_documents",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_documents_user_id_users_id_fk": {
+ "name": "topic_documents_user_id_users_id_fk",
+ "tableFrom": "topic_documents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_documents_workspace_id_workspaces_id_fk": {
+ "name": "topic_documents_workspace_id_workspaces_id_fk",
+ "tableFrom": "topic_documents",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "topic_documents_document_id_topic_id_pk": {
+ "name": "topic_documents_document_id_topic_id_pk",
+ "columns": ["document_id", "topic_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.topic_shares": {
+ "name": "topic_shares",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'private'"
+ },
+ "page_view_count": {
+ "name": "page_view_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "topic_shares_topic_id_unique": {
+ "name": "topic_shares_topic_id_unique",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_shares_user_id_idx": {
+ "name": "topic_shares_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_shares_workspace_id_idx": {
+ "name": "topic_shares_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topic_shares_topic_id_topics_id_fk": {
+ "name": "topic_shares_topic_id_topics_id_fk",
+ "tableFrom": "topic_shares",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_shares_user_id_users_id_fk": {
+ "name": "topic_shares_user_id_users_id_fk",
+ "tableFrom": "topic_shares",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_shares_workspace_id_workspaces_id_fk": {
+ "name": "topic_shares_workspace_id_workspaces_id_fk",
+ "tableFrom": "topic_shares",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.topics": {
+ "name": "topics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "favorite": {
+ "name": "favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_working_directory_id": {
+ "name": "project_working_directory_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "history_summary": {
+ "name": "history_summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_cost": {
+ "name": "total_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_input_tokens": {
+ "name": "total_input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_output_tokens": {
+ "name": "total_output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_tokens": {
+ "name": "total_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cost": {
+ "name": "cost",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "usage": {
+ "name": "usage",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sender_id": {
+ "name": "sender_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "topics_client_id_user_id_unique": {
+ "name": "topics_client_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_created_at_idx": {
+ "name": "topics_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_user_id_idx": {
+ "name": "topics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_id_user_id_idx": {
+ "name": "topics_id_user_id_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_session_id_idx": {
+ "name": "topics_session_id_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_group_id_idx": {
+ "name": "topics_group_id_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_agent_id_idx": {
+ "name": "topics_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_project_id_idx": {
+ "name": "topics_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"topics\".\"project_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_project_working_directory_id_idx": {
+ "name": "topics_project_working_directory_id_idx",
+ "columns": [
+ {
+ "expression": "project_working_directory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"topics\".\"project_working_directory_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_trigger_idx": {
+ "name": "topics_trigger_idx",
+ "columns": [
+ {
+ "expression": "trigger",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_status_idx": {
+ "name": "topics_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_model_idx": {
+ "name": "topics_model_idx",
+ "columns": [
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_provider_idx": {
+ "name": "topics_provider_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_user_id_completed_at_idx": {
+ "name": "topics_user_id_completed_at_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "completed_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_sender_id_idx": {
+ "name": "topics_sender_id_idx",
+ "columns": [
+ {
+ "expression": "sender_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_workspace_id_idx": {
+ "name": "topics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topics_extract_status_gin_idx": {
+ "name": "topics_extract_status_gin_idx",
+ "columns": [
+ {
+ "expression": "(metadata->'userMemoryExtractStatus') jsonb_path_ops",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topics_session_id_sessions_id_fk": {
+ "name": "topics_session_id_sessions_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "sessions",
+ "columnsFrom": ["session_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topics_agent_id_agents_id_fk": {
+ "name": "topics_agent_id_agents_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topics_group_id_chat_groups_id_fk": {
+ "name": "topics_group_id_chat_groups_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "chat_groups",
+ "columnsFrom": ["group_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topics_project_id_projects_id_fk": {
+ "name": "topics_project_id_projects_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "topics_project_working_directory_id_project_working_directories_id_fk": {
+ "name": "topics_project_working_directory_id_project_working_directories_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "project_working_directories",
+ "columnsFrom": ["project_working_directory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "topics_user_id_users_id_fk": {
+ "name": "topics_user_id_users_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topics_workspace_id_workspaces_id_fk": {
+ "name": "topics_workspace_id_workspaces_id_fk",
+ "tableFrom": "topics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.topic_comment_mentions": {
+ "name": "topic_comment_mentions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "comment_id": {
+ "name": "comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mentioned_user_id": {
+ "name": "mentioned_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "topic_comment_mentions_comment_id_mentioned_user_id_unique": {
+ "name": "topic_comment_mentions_comment_id_mentioned_user_id_unique",
+ "columns": [
+ {
+ "expression": "comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "mentioned_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comment_mentions_mentioned_user_id_created_at_idx": {
+ "name": "topic_comment_mentions_mentioned_user_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "mentioned_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comment_mentions_workspace_id_idx": {
+ "name": "topic_comment_mentions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topic_comment_mentions_comment_id_topic_comments_id_fk": {
+ "name": "topic_comment_mentions_comment_id_topic_comments_id_fk",
+ "tableFrom": "topic_comment_mentions",
+ "tableTo": "topic_comments",
+ "columnsFrom": ["comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_comment_mentions_mentioned_user_id_users_id_fk": {
+ "name": "topic_comment_mentions_mentioned_user_id_users_id_fk",
+ "tableFrom": "topic_comment_mentions",
+ "tableTo": "users",
+ "columnsFrom": ["mentioned_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_comment_mentions_workspace_id_workspaces_id_fk": {
+ "name": "topic_comment_mentions_workspace_id_workspaces_id_fk",
+ "tableFrom": "topic_comment_mentions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.topic_comments": {
+ "name": "topic_comments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_comment_id": {
+ "name": "parent_comment_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_user_id": {
+ "name": "author_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "editor_data": {
+ "name": "editor_data",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anchor_preview": {
+ "name": "anchor_preview",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderated_at": {
+ "name": "moderated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderated_by_user_id": {
+ "name": "moderated_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "moderation_expires_at": {
+ "name": "moderation_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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "topic_comments_topic_id_author_user_id_client_id_unique": {
+ "name": "topic_comments_topic_id_author_user_id_client_id_unique",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_parent_comment_id_created_at_id_idx": {
+ "name": "topic_comments_parent_comment_id_created_at_id_idx",
+ "columns": [
+ {
+ "expression": "parent_comment_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_topic_id_created_at_id_idx": {
+ "name": "topic_comments_topic_id_created_at_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_topic_id_message_id_idx": {
+ "name": "topic_comments_topic_id_message_id_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_message_id_idx": {
+ "name": "topic_comments_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_author_user_id_idx": {
+ "name": "topic_comments_author_user_id_idx",
+ "columns": [
+ {
+ "expression": "author_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_moderation_expires_at_idx": {
+ "name": "topic_comments_moderation_expires_at_idx",
+ "columns": [
+ {
+ "expression": "moderation_expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_moderated_by_user_id_idx": {
+ "name": "topic_comments_moderated_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "moderated_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "topic_comments_workspace_id_idx": {
+ "name": "topic_comments_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "topic_comments_topic_id_topics_id_fk": {
+ "name": "topic_comments_topic_id_topics_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_comments_message_id_messages_id_fk": {
+ "name": "topic_comments_message_id_messages_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "topic_comments_parent_comment_id_topic_comments_id_fk": {
+ "name": "topic_comments_parent_comment_id_topic_comments_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "topic_comments",
+ "columnsFrom": ["parent_comment_id"],
+ "columnsTo": ["id"],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "topic_comments_author_user_id_users_id_fk": {
+ "name": "topic_comments_author_user_id_users_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "users",
+ "columnsFrom": ["author_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "topic_comments_workspace_id_workspaces_id_fk": {
+ "name": "topic_comments_workspace_id_workspaces_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "topic_comments_moderated_by_user_id_users_id_fk": {
+ "name": "topic_comments_moderated_by_user_id_users_id_fk",
+ "tableFrom": "topic_comments",
+ "tableTo": "users",
+ "columnsFrom": ["moderated_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "topic_comments_anchored_requires_preview": {
+ "name": "topic_comments_anchored_requires_preview",
+ "value": "\"topic_comments\".\"message_id\" IS NULL OR \"topic_comments\".\"anchor_preview\" IS NOT NULL"
+ },
+ "topic_comments_reply_has_no_anchor": {
+ "name": "topic_comments_reply_has_no_anchor",
+ "value": "\"topic_comments\".\"parent_comment_id\" IS NULL OR (\"topic_comments\".\"message_id\" IS NULL AND \"topic_comments\".\"anchor_preview\" IS NULL)"
+ },
+ "topic_comments_moderation_window_consistent": {
+ "name": "topic_comments_moderation_window_consistent",
+ "value": "(\"topic_comments\".\"moderated_at\" IS NULL) = (\"topic_comments\".\"moderation_expires_at\" IS NULL)"
+ },
+ "topic_comments_deleted_not_recoverable": {
+ "name": "topic_comments_deleted_not_recoverable",
+ "value": "\"topic_comments\".\"deleted_at\" IS NULL OR \"topic_comments\".\"moderated_at\" IS NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.trash_items": {
+ "name": "trash_items",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "meta": {
+ "name": "meta",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "root_id": {
+ "name": "root_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_by_user_id": {
+ "name": "deleted_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "trash_items_resource_unique": {
+ "name": "trash_items_resource_unique",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_personal_listing_idx": {
+ "name": "trash_items_personal_listing_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"trash_items\".\"root_id\" IS NULL AND \"trash_items\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_workspace_listing_idx": {
+ "name": "trash_items_workspace_listing_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"trash_items\".\"root_id\" IS NULL AND \"trash_items\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_expires_at_idx": {
+ "name": "trash_items_expires_at_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"trash_items\".\"root_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_root_id_idx": {
+ "name": "trash_items_root_id_idx",
+ "columns": [
+ {
+ "expression": "root_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_user_id_idx": {
+ "name": "trash_items_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "trash_items_deleted_by_user_id_idx": {
+ "name": "trash_items_deleted_by_user_id_idx",
+ "columns": [
+ {
+ "expression": "deleted_by_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "trash_items_root_id_trash_items_id_fk": {
+ "name": "trash_items_root_id_trash_items_id_fk",
+ "tableFrom": "trash_items",
+ "tableTo": "trash_items",
+ "columnsFrom": ["root_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "trash_items_user_id_users_id_fk": {
+ "name": "trash_items_user_id_users_id_fk",
+ "tableFrom": "trash_items",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "trash_items_workspace_id_workspaces_id_fk": {
+ "name": "trash_items_workspace_id_workspaces_id_fk",
+ "tableFrom": "trash_items",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "trash_items_deleted_by_user_id_users_id_fk": {
+ "name": "trash_items_deleted_by_user_id_users_id_fk",
+ "tableFrom": "trash_items",
+ "tableTo": "users",
+ "columnsFrom": ["deleted_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_settings": {
+ "name": "user_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "tts": {
+ "name": "tts",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "hotkey": {
+ "name": "hotkey",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_vaults": {
+ "name": "key_vaults",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "general": {
+ "name": "general",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "language_model": {
+ "name": "language_model",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "system_agent": {
+ "name": "system_agent",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "default_agent": {
+ "name": "default_agent",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "market": {
+ "name": "market",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory": {
+ "name": "memory",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool": {
+ "name": "tool",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notification": {
+ "name": "notification",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_settings_id_users_id_fk": {
+ "name": "user_settings_id_users_id_fk",
+ "tableFrom": "user_settings",
+ "tableTo": "users",
+ "columnsFrom": ["id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "normalized_email": {
+ "name": "normalized_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "phone": {
+ "name": "phone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_name": {
+ "name": "last_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "full_name": {
+ "name": "full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "interests": {
+ "name": "interests",
+ "type": "varchar(64)[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_onboarded": {
+ "name": "is_onboarded",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "agent_onboarding": {
+ "name": "agent_onboarding",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "onboarding": {
+ "name": "onboarding",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "clerk_created_at": {
+ "name": "clerk_created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "email_verified_at": {
+ "name": "email_verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "preference": {
+ "name": "preference",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "banned": {
+ "name": "banned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "ban_reason": {
+ "name": "ban_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ban_expires": {
+ "name": "ban_expires",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "two_factor_enabled": {
+ "name": "two_factor_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "phone_number_verified": {
+ "name": "phone_number_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_active_at": {
+ "name": "last_active_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "users_email_idx": {
+ "name": "users_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_username_idx": {
+ "name": "users_username_idx",
+ "columns": [
+ {
+ "expression": "username",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_created_at_idx": {
+ "name": "users_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "users_banned_true_created_at_idx": {
+ "name": "users_banned_true_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"users\".\"banned\" = true",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "users_username_unique": {
+ "name": "users_username_unique",
+ "nullsNotDistinct": false,
+ "columns": ["username"]
+ },
+ "users_email_unique": {
+ "name": "users_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["email"]
+ },
+ "users_normalized_email_unique": {
+ "name": "users_normalized_email_unique",
+ "nullsNotDistinct": false,
+ "columns": ["normalized_email"]
+ },
+ "users_phone_unique": {
+ "name": "users_phone_unique",
+ "nullsNotDistinct": false,
+ "columns": ["phone"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories": {
+ "name": "user_memories",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_category": {
+ "name": "memory_category",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_layer": {
+ "name": "memory_layer",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_type": {
+ "name": "memory_type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary_vector_1024": {
+ "name": "summary_vector_1024",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "details": {
+ "name": "details",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "details_vector_1024": {
+ "name": "details_vector_1024",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_count": {
+ "name": "accessed_count",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "last_accessed_at": {
+ "name": "last_accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_summary_vector_1024_index": {
+ "name": "user_memories_summary_vector_1024_index",
+ "columns": [
+ {
+ "expression": "summary_vector_1024",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_details_vector_1024_index": {
+ "name": "user_memories_details_vector_1024_index",
+ "columns": [
+ {
+ "expression": "details_vector_1024",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_user_id_index": {
+ "name": "user_memories_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_user_id_users_id_fk": {
+ "name": "user_memories_user_id_users_id_fk",
+ "tableFrom": "user_memories",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories_activities": {
+ "name": "user_memories_activities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "starts_at": {
+ "name": "starts_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ends_at": {
+ "name": "ends_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_objects": {
+ "name": "associated_objects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_subjects": {
+ "name": "associated_subjects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_locations": {
+ "name": "associated_locations",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notes": {
+ "name": "notes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "narrative": {
+ "name": "narrative",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "narrative_vector": {
+ "name": "narrative_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback": {
+ "name": "feedback",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "feedback_vector": {
+ "name": "feedback_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_activities_narrative_vector_index": {
+ "name": "user_memories_activities_narrative_vector_index",
+ "columns": [
+ {
+ "expression": "narrative_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_activities_feedback_vector_index": {
+ "name": "user_memories_activities_feedback_vector_index",
+ "columns": [
+ {
+ "expression": "feedback_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_activities_type_index": {
+ "name": "user_memories_activities_type_index",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_user_id_index": {
+ "name": "user_memories_activities_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_user_memory_id_index": {
+ "name": "user_memories_activities_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_activities_status_index": {
+ "name": "user_memories_activities_status_index",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_activities_user_id_users_id_fk": {
+ "name": "user_memories_activities_user_id_users_id_fk",
+ "tableFrom": "user_memories_activities",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_activities_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_activities_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_activities",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories_contexts": {
+ "name": "user_memories_contexts",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_ids": {
+ "name": "user_memory_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_objects": {
+ "name": "associated_objects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "associated_subjects": {
+ "name": "associated_subjects",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description_vector": {
+ "name": "description_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "current_status": {
+ "name": "current_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score_impact": {
+ "name": "score_impact",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "score_urgency": {
+ "name": "score_urgency",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_contexts_description_vector_index": {
+ "name": "user_memories_contexts_description_vector_index",
+ "columns": [
+ {
+ "expression": "description_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_contexts_type_index": {
+ "name": "user_memories_contexts_type_index",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_contexts_user_id_index": {
+ "name": "user_memories_contexts_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_contexts_user_memory_ids_gin_idx": {
+ "name": "user_memories_contexts_user_memory_ids_gin_idx",
+ "columns": [
+ {
+ "expression": "user_memory_ids",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "gin",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_contexts_user_id_users_id_fk": {
+ "name": "user_memories_contexts_user_id_users_id_fk",
+ "tableFrom": "user_memories_contexts",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories_experiences": {
+ "name": "user_memories_experiences",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "situation": {
+ "name": "situation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "situation_vector": {
+ "name": "situation_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning": {
+ "name": "reasoning",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "possible_outcome": {
+ "name": "possible_outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action_vector": {
+ "name": "action_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_learning": {
+ "name": "key_learning",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key_learning_vector": {
+ "name": "key_learning_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score_confidence": {
+ "name": "score_confidence",
+ "type": "real",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_experiences_situation_vector_index": {
+ "name": "user_memories_experiences_situation_vector_index",
+ "columns": [
+ {
+ "expression": "situation_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_experiences_action_vector_index": {
+ "name": "user_memories_experiences_action_vector_index",
+ "columns": [
+ {
+ "expression": "action_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_experiences_key_learning_vector_index": {
+ "name": "user_memories_experiences_key_learning_vector_index",
+ "columns": [
+ {
+ "expression": "key_learning_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_experiences_type_index": {
+ "name": "user_memories_experiences_type_index",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_experiences_user_id_index": {
+ "name": "user_memories_experiences_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_experiences_user_memory_id_index": {
+ "name": "user_memories_experiences_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_experiences_user_id_users_id_fk": {
+ "name": "user_memories_experiences_user_id_users_id_fk",
+ "tableFrom": "user_memories_experiences",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_experiences_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_experiences_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_experiences",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories_identities": {
+ "name": "user_memories_identities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description_vector": {
+ "name": "description_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "episodic_date": {
+ "name": "episodic_date",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "relationship": {
+ "name": "relationship",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_identities_description_vector_index": {
+ "name": "user_memories_identities_description_vector_index",
+ "columns": [
+ {
+ "expression": "description_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_identities_type_index": {
+ "name": "user_memories_identities_type_index",
+ "columns": [
+ {
+ "expression": "type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_identities_user_id_index": {
+ "name": "user_memories_identities_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_identities_user_memory_id_index": {
+ "name": "user_memories_identities_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_identities_user_id_users_id_fk": {
+ "name": "user_memories_identities_user_id_users_id_fk",
+ "tableFrom": "user_memories_identities",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_identities_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_identities_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_identities",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memories_preferences": {
+ "name": "user_memories_preferences",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_memory_id": {
+ "name": "user_memory_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conclusion_directives": {
+ "name": "conclusion_directives",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "conclusion_directives_vector": {
+ "name": "conclusion_directives_vector",
+ "type": "vector(1024)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suggestions": {
+ "name": "suggestions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "score_priority": {
+ "name": "score_priority",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_memories_preferences_conclusion_directives_vector_index": {
+ "name": "user_memories_preferences_conclusion_directives_vector_index",
+ "columns": [
+ {
+ "expression": "conclusion_directives_vector",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last",
+ "opclass": "vector_cosine_ops"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "hnsw",
+ "with": {}
+ },
+ "user_memories_preferences_user_id_index": {
+ "name": "user_memories_preferences_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_memories_preferences_user_memory_id_index": {
+ "name": "user_memories_preferences_user_memory_id_index",
+ "columns": [
+ {
+ "expression": "user_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memories_preferences_user_id_users_id_fk": {
+ "name": "user_memories_preferences_user_id_users_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memories_preferences_user_memory_id_user_memories_id_fk": {
+ "name": "user_memories_preferences_user_memory_id_user_memories_id_fk",
+ "tableFrom": "user_memories_preferences",
+ "tableTo": "user_memories",
+ "columnsFrom": ["user_memory_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memory_persona_document_histories": {
+ "name": "user_memory_persona_document_histories",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona_id": {
+ "name": "persona_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "profile": {
+ "name": "profile",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "snapshot_persona": {
+ "name": "snapshot_persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot_tagline": {
+ "name": "snapshot_tagline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning": {
+ "name": "reasoning",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "diff_persona": {
+ "name": "diff_persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "diff_tagline": {
+ "name": "diff_tagline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snapshot": {
+ "name": "snapshot",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "edited_by": {
+ "name": "edited_by",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'agent'"
+ },
+ "memory_ids": {
+ "name": "memory_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_ids": {
+ "name": "source_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "previous_version": {
+ "name": "previous_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_version": {
+ "name": "next_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_persona_document_histories_persona_id_index": {
+ "name": "user_persona_document_histories_persona_id_index",
+ "columns": [
+ {
+ "expression": "persona_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_persona_document_histories_user_id_index": {
+ "name": "user_persona_document_histories_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_persona_document_histories_profile_index": {
+ "name": "user_persona_document_histories_profile_index",
+ "columns": [
+ {
+ "expression": "profile",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memory_persona_document_histories_user_id_users_id_fk": {
+ "name": "user_memory_persona_document_histories_user_id_users_id_fk",
+ "tableFrom": "user_memory_persona_document_histories",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk": {
+ "name": "user_memory_persona_document_histories_persona_id_user_memory_persona_documents_id_fk",
+ "tableFrom": "user_memory_persona_document_histories",
+ "tableTo": "user_memory_persona_documents",
+ "columnsFrom": ["persona_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_memory_persona_documents": {
+ "name": "user_memory_persona_documents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(255)",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "profile": {
+ "name": "profile",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "tagline": {
+ "name": "tagline",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "persona": {
+ "name": "persona",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_ids": {
+ "name": "memory_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_ids": {
+ "name": "source_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "user_persona_documents_user_id_profile_unique": {
+ "name": "user_persona_documents_user_id_profile_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "profile",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_persona_documents_user_id_index": {
+ "name": "user_persona_documents_user_id_index",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_memory_persona_documents_user_id_users_id_fk": {
+ "name": "user_memory_persona_documents_user_id_users_id_fk",
+ "tableFrom": "user_memory_persona_documents",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.acceptances": {
+ "name": "acceptances",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject_id": {
+ "name": "subject_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "requirement": {
+ "name": "requirement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "visual_render": {
+ "name": "visual_render",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "acceptances_user_id_idx": {
+ "name": "acceptances_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_workspace_id_idx": {
+ "name": "acceptances_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_project_id_idx": {
+ "name": "acceptances_project_id_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_subject_idx": {
+ "name": "acceptances_subject_idx",
+ "columns": [
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_status_idx": {
+ "name": "acceptances_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_workspace_visibility_idx": {
+ "name": "acceptances_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_personal_subject_unique": {
+ "name": "acceptances_personal_subject_unique",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"acceptances\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "acceptances_workspace_subject_unique": {
+ "name": "acceptances_workspace_subject_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"acceptances\".\"workspace_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "acceptances_user_id_users_id_fk": {
+ "name": "acceptances_user_id_users_id_fk",
+ "tableFrom": "acceptances",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptances_workspace_id_workspaces_id_fk": {
+ "name": "acceptances_workspace_id_workspaces_id_fk",
+ "tableFrom": "acceptances",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "acceptances_project_id_projects_id_fk": {
+ "name": "acceptances_project_id_projects_id_fk",
+ "tableFrom": "acceptances",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_check_results": {
+ "name": "verify_check_results",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "verify_run_id": {
+ "name": "verify_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_item_id": {
+ "name": "check_item_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_criterion_id": {
+ "name": "source_criterion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_item_title": {
+ "name": "check_item_title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "required": {
+ "name": "required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "check_item_index": {
+ "name": "check_item_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verifier_type": {
+ "name": "verifier_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "verifier_config_hash": {
+ "name": "verifier_config_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verifier_operation_id": {
+ "name": "verifier_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verifier_tracing_id": {
+ "name": "verifier_tracing_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "verdict": {
+ "name": "verdict",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "toulmin": {
+ "name": "toulmin",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "suggestion": {
+ "name": "suggestion",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_decision": {
+ "name": "user_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_decision_detail": {
+ "name": "user_decision_detail",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_false_positive": {
+ "name": "is_false_positive",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_false_negative": {
+ "name": "is_false_negative",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "repair_operation_id": {
+ "name": "repair_operation_id",
+ "type": "text",
+ "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
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_check_results_criterion_created_idx": {
+ "name": "verify_check_results_criterion_created_idx",
+ "columns": [
+ {
+ "expression": "source_criterion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verify_run_id_idx": {
+ "name": "verify_check_results_verify_run_id_idx",
+ "columns": [
+ {
+ "expression": "verify_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_operation_id_idx": {
+ "name": "verify_check_results_operation_id_idx",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_user_id_idx": {
+ "name": "verify_check_results_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verify_run_id_check_item_id_unique": {
+ "name": "verify_check_results_verify_run_id_check_item_id_unique",
+ "columns": [
+ {
+ "expression": "verify_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "check_item_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verifier_type_idx": {
+ "name": "verify_check_results_verifier_type_idx",
+ "columns": [
+ {
+ "expression": "verifier_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verifier_operation_id_idx": {
+ "name": "verify_check_results_verifier_operation_id_idx",
+ "columns": [
+ {
+ "expression": "verifier_operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verifier_tracing_id_idx": {
+ "name": "verify_check_results_verifier_tracing_id_idx",
+ "columns": [
+ {
+ "expression": "verifier_tracing_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_status_idx": {
+ "name": "verify_check_results_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_verdict_idx": {
+ "name": "verify_check_results_verdict_idx",
+ "columns": [
+ {
+ "expression": "verdict",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_repair_operation_id_idx": {
+ "name": "verify_check_results_repair_operation_id_idx",
+ "columns": [
+ {
+ "expression": "repair_operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_check_results_workspace_id_idx": {
+ "name": "verify_check_results_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_check_results_verify_run_id_verify_runs_id_fk": {
+ "name": "verify_check_results_verify_run_id_verify_runs_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "verify_runs",
+ "columnsFrom": ["verify_run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_operation_id_agent_operations_id_fk": {
+ "name": "verify_check_results_operation_id_agent_operations_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_user_id_users_id_fk": {
+ "name": "verify_check_results_user_id_users_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_workspace_id_workspaces_id_fk": {
+ "name": "verify_check_results_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_source_criterion_id_verify_criteria_id_fk": {
+ "name": "verify_check_results_source_criterion_id_verify_criteria_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "verify_criteria",
+ "columnsFrom": ["source_criterion_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_verifier_operation_id_agent_operations_id_fk": {
+ "name": "verify_check_results_verifier_operation_id_agent_operations_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["verifier_operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk": {
+ "name": "verify_check_results_verifier_tracing_id_llm_generation_tracing_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "llm_generation_tracing",
+ "columnsFrom": ["verifier_tracing_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_check_results_repair_operation_id_agent_operations_id_fk": {
+ "name": "verify_check_results_repair_operation_id_agent_operations_id_fk",
+ "tableFrom": "verify_check_results",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["repair_operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_criteria": {
+ "name": "verify_criteria",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "definition": {
+ "name": "definition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tags": {
+ "name": "tags",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "required": {
+ "name": "required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "verifier_type": {
+ "name": "verifier_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "verifier_config": {
+ "name": "verifier_config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "on_fail": {
+ "name": "on_fail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'manual'"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_criteria_user_id_idx": {
+ "name": "verify_criteria_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_criteria_verifier_type_idx": {
+ "name": "verify_criteria_verifier_type_idx",
+ "columns": [
+ {
+ "expression": "verifier_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_criteria_document_id_idx": {
+ "name": "verify_criteria_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_criteria_workspace_id_idx": {
+ "name": "verify_criteria_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_criteria_user_id_users_id_fk": {
+ "name": "verify_criteria_user_id_users_id_fk",
+ "tableFrom": "verify_criteria",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_criteria_document_id_documents_id_fk": {
+ "name": "verify_criteria_document_id_documents_id_fk",
+ "tableFrom": "verify_criteria",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_criteria_workspace_id_workspaces_id_fk": {
+ "name": "verify_criteria_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_criteria",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_evidence": {
+ "name": "verify_evidence",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "check_result_id": {
+ "name": "check_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "file_id": {
+ "name": "file_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_by": {
+ "name": "captured_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_evidence_check_result_id_idx": {
+ "name": "verify_evidence_check_result_id_idx",
+ "columns": [
+ {
+ "expression": "check_result_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_evidence_document_id_idx": {
+ "name": "verify_evidence_document_id_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_evidence_file_id_idx": {
+ "name": "verify_evidence_file_id_idx",
+ "columns": [
+ {
+ "expression": "file_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_evidence_user_id_idx": {
+ "name": "verify_evidence_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_evidence_workspace_id_idx": {
+ "name": "verify_evidence_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_evidence_check_result_id_verify_check_results_id_fk": {
+ "name": "verify_evidence_check_result_id_verify_check_results_id_fk",
+ "tableFrom": "verify_evidence",
+ "tableTo": "verify_check_results",
+ "columnsFrom": ["check_result_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_evidence_document_id_documents_id_fk": {
+ "name": "verify_evidence_document_id_documents_id_fk",
+ "tableFrom": "verify_evidence",
+ "tableTo": "documents",
+ "columnsFrom": ["document_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_evidence_file_id_files_id_fk": {
+ "name": "verify_evidence_file_id_files_id_fk",
+ "tableFrom": "verify_evidence",
+ "tableTo": "files",
+ "columnsFrom": ["file_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_evidence_user_id_users_id_fk": {
+ "name": "verify_evidence_user_id_users_id_fk",
+ "tableFrom": "verify_evidence",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_evidence_workspace_id_workspaces_id_fk": {
+ "name": "verify_evidence_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_evidence",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_reports": {
+ "name": "verify_reports",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "verify_run_id": {
+ "name": "verify_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verdict": {
+ "name": "verdict",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "overall_confidence": {
+ "name": "overall_confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "total_checks": {
+ "name": "total_checks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "passed_checks": {
+ "name": "passed_checks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "failed_checks": {
+ "name": "failed_checks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uncertain_checks": {
+ "name": "uncertain_checks",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reviewed_by_user": {
+ "name": "reviewed_by_user",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "generated_by": {
+ "name": "generated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'system'"
+ },
+ "generated_at": {
+ "name": "generated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_reports_verify_run_id_unique": {
+ "name": "verify_reports_verify_run_id_unique",
+ "columns": [
+ {
+ "expression": "verify_run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_reports_operation_id_idx": {
+ "name": "verify_reports_operation_id_idx",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_reports_user_id_idx": {
+ "name": "verify_reports_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_reports_workspace_id_idx": {
+ "name": "verify_reports_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_reports_verify_run_id_verify_runs_id_fk": {
+ "name": "verify_reports_verify_run_id_verify_runs_id_fk",
+ "tableFrom": "verify_reports",
+ "tableTo": "verify_runs",
+ "columnsFrom": ["verify_run_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_reports_operation_id_agent_operations_id_fk": {
+ "name": "verify_reports_operation_id_agent_operations_id_fk",
+ "tableFrom": "verify_reports",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_reports_user_id_users_id_fk": {
+ "name": "verify_reports_user_id_users_id_fk",
+ "tableFrom": "verify_reports",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_reports_workspace_id_workspaces_id_fk": {
+ "name": "verify_reports_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_reports",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_review_predictions": {
+ "name": "verify_review_predictions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "check_result_id": {
+ "name": "check_result_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt_version": {
+ "name": "prompt_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status_reason": {
+ "name": "status_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confidence": {
+ "name": "confidence",
+ "type": "numeric(3, 2)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "comment": {
+ "name": "comment",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rationale": {
+ "name": "rationale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "annotations": {
+ "name": "annotations",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "adjudication": {
+ "name": "adjudication",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "adjudication_edit": {
+ "name": "adjudication_edit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "adjudicated_at": {
+ "name": "adjudicated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latency_ms": {
+ "name": "latency_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt_tokens": {
+ "name": "prompt_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completion_tokens": {
+ "name": "completion_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_review_predictions_check_result_id_idx": {
+ "name": "verify_review_predictions_check_result_id_idx",
+ "columns": [
+ {
+ "expression": "check_result_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_review_predictions_user_id_idx": {
+ "name": "verify_review_predictions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_review_predictions_workspace_id_idx": {
+ "name": "verify_review_predictions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_review_predictions_model_idx": {
+ "name": "verify_review_predictions_model_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_review_predictions_result_model_prompt_unique": {
+ "name": "verify_review_predictions_result_model_prompt_unique",
+ "columns": [
+ {
+ "expression": "check_result_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "prompt_version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_review_predictions_check_result_id_verify_check_results_id_fk": {
+ "name": "verify_review_predictions_check_result_id_verify_check_results_id_fk",
+ "tableFrom": "verify_review_predictions",
+ "tableTo": "verify_check_results",
+ "columnsFrom": ["check_result_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_review_predictions_user_id_users_id_fk": {
+ "name": "verify_review_predictions_user_id_users_id_fk",
+ "tableFrom": "verify_review_predictions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_review_predictions_workspace_id_workspaces_id_fk": {
+ "name": "verify_review_predictions_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_review_predictions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "verify_review_predictions_action_matches_status": {
+ "name": "verify_review_predictions_action_matches_status",
+ "value": "(\"verify_review_predictions\".\"status\" = 'judged') = (\"verify_review_predictions\".\"action\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.verify_rubric_criteria": {
+ "name": "verify_rubric_criteria",
+ "schema": "",
+ "columns": {
+ "rubric_id": {
+ "name": "rubric_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "criterion_id": {
+ "name": "criterion_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sort_order": {
+ "name": "sort_order",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_rubric_criteria_criterion_id_idx": {
+ "name": "verify_rubric_criteria_criterion_id_idx",
+ "columns": [
+ {
+ "expression": "criterion_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_rubric_criteria_user_id_idx": {
+ "name": "verify_rubric_criteria_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_rubric_criteria_workspace_id_idx": {
+ "name": "verify_rubric_criteria_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk": {
+ "name": "verify_rubric_criteria_rubric_id_verify_rubrics_id_fk",
+ "tableFrom": "verify_rubric_criteria",
+ "tableTo": "verify_rubrics",
+ "columnsFrom": ["rubric_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_rubric_criteria_criterion_id_verify_criteria_id_fk": {
+ "name": "verify_rubric_criteria_criterion_id_verify_criteria_id_fk",
+ "tableFrom": "verify_rubric_criteria",
+ "tableTo": "verify_criteria",
+ "columnsFrom": ["criterion_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_rubric_criteria_user_id_users_id_fk": {
+ "name": "verify_rubric_criteria_user_id_users_id_fk",
+ "tableFrom": "verify_rubric_criteria",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_rubric_criteria_workspace_id_workspaces_id_fk": {
+ "name": "verify_rubric_criteria_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_rubric_criteria",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "verify_rubric_criteria_rubric_id_criterion_id_pk": {
+ "name": "verify_rubric_criteria_rubric_id_criterion_id_pk",
+ "columns": ["rubric_id", "criterion_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_rubrics": {
+ "name": "verify_rubrics",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_rubrics_user_id_idx": {
+ "name": "verify_rubrics_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_rubrics_workspace_id_idx": {
+ "name": "verify_rubrics_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_rubrics_user_id_users_id_fk": {
+ "name": "verify_rubrics_user_id_users_id_fk",
+ "tableFrom": "verify_rubrics",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_rubrics_workspace_id_workspaces_id_fk": {
+ "name": "verify_rubrics_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_rubrics",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verify_runs": {
+ "name": "verify_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "acceptance_id": {
+ "name": "acceptance_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "round_index": {
+ "name": "round_index",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'agent'"
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "scenario": {
+ "name": "scenario",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "context": {
+ "name": "context",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan": {
+ "name": "plan",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "flow_snapshots": {
+ "name": "flow_snapshots",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "plan_confirmed_at": {
+ "name": "plan_confirmed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_decision": {
+ "name": "user_decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decision_detail": {
+ "name": "decision_detail",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verify_runs_user_id_idx": {
+ "name": "verify_runs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_workspace_id_idx": {
+ "name": "verify_runs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_acceptance_id_idx": {
+ "name": "verify_runs_acceptance_id_idx",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_acceptance_round_unique": {
+ "name": "verify_runs_acceptance_round_unique",
+ "columns": [
+ {
+ "expression": "acceptance_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "round_index",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_operation_id_unique": {
+ "name": "verify_runs_operation_id_unique",
+ "columns": [
+ {
+ "expression": "operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_source_idx": {
+ "name": "verify_runs_source_idx",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "verify_runs_user_decision_idx": {
+ "name": "verify_runs_user_decision_idx",
+ "columns": [
+ {
+ "expression": "user_decision",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "verify_runs_user_id_users_id_fk": {
+ "name": "verify_runs_user_id_users_id_fk",
+ "tableFrom": "verify_runs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_runs_workspace_id_workspaces_id_fk": {
+ "name": "verify_runs_workspace_id_workspaces_id_fk",
+ "tableFrom": "verify_runs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "verify_runs_acceptance_id_acceptances_id_fk": {
+ "name": "verify_runs_acceptance_id_acceptances_id_fk",
+ "tableFrom": "verify_runs",
+ "tableTo": "acceptances",
+ "columnsFrom": ["acceptance_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "verify_runs_operation_id_agent_operations_id_fk": {
+ "name": "verify_runs_operation_id_agent_operations_id_fk",
+ "tableFrom": "verify_runs",
+ "tableTo": "agent_operations",
+ "columnsFrom": ["operation_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "verify_runs_acceptance_requires_round": {
+ "name": "verify_runs_acceptance_requires_round",
+ "value": "\"verify_runs\".\"acceptance_id\" IS NULL OR \"verify_runs\".\"round_index\" IS NOT NULL"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.widget_runs": {
+ "name": "widget_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "widget_id": {
+ "name": "widget_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version_id": {
+ "name": "version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'running'"
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "duration_ms": {
+ "name": "duration_ms",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "exit_code": {
+ "name": "exit_code",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stdout": {
+ "name": "stdout",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "stderr": {
+ "name": "stderr",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sandbox_id": {
+ "name": "sandbox_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "operation_id": {
+ "name": "operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "widget_runs_widget_id_created_at_idx": {
+ "name": "widget_runs_widget_id_created_at_idx",
+ "columns": [
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_runs_version_id_idx": {
+ "name": "widget_runs_version_id_idx",
+ "columns": [
+ {
+ "expression": "version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_runs_user_id_idx": {
+ "name": "widget_runs_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_runs_workspace_id_idx": {
+ "name": "widget_runs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "widget_runs_widget_id_widgets_id_fk": {
+ "name": "widget_runs_widget_id_widgets_id_fk",
+ "tableFrom": "widget_runs",
+ "tableTo": "widgets",
+ "columnsFrom": ["widget_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_runs_version_id_widget_versions_id_fk": {
+ "name": "widget_runs_version_id_widget_versions_id_fk",
+ "tableFrom": "widget_runs",
+ "tableTo": "widget_versions",
+ "columnsFrom": ["version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_runs_user_id_users_id_fk": {
+ "name": "widget_runs_user_id_users_id_fk",
+ "tableFrom": "widget_runs",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_runs_workspace_id_workspaces_id_fk": {
+ "name": "widget_runs_workspace_id_workspaces_id_fk",
+ "tableFrom": "widget_runs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.widget_versions": {
+ "name": "widget_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "widget_id": {
+ "name": "widget_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "runtime": {
+ "name": "runtime",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "script": {
+ "name": "script",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_hash": {
+ "name": "content_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "manifest": {
+ "name": "manifest",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_type": {
+ "name": "output_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "view": {
+ "name": "view",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'draft'"
+ },
+ "change_note": {
+ "name": "change_note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_by_user_id": {
+ "name": "published_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_type": {
+ "name": "source_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_agent_id": {
+ "name": "source_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_topic_id": {
+ "name": "source_topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_message_id": {
+ "name": "source_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_operation_id": {
+ "name": "source_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "parent_version_id": {
+ "name": "parent_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "widget_versions_widget_id_version_unique": {
+ "name": "widget_versions_widget_id_version_unique",
+ "columns": [
+ {
+ "expression": "widget_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_versions_user_id_idx": {
+ "name": "widget_versions_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_versions_workspace_id_idx": {
+ "name": "widget_versions_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_versions_source_agent_id_idx": {
+ "name": "widget_versions_source_agent_id_idx",
+ "columns": [
+ {
+ "expression": "source_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_versions_source_topic_id_idx": {
+ "name": "widget_versions_source_topic_id_idx",
+ "columns": [
+ {
+ "expression": "source_topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widget_versions_parent_version_id_idx": {
+ "name": "widget_versions_parent_version_id_idx",
+ "columns": [
+ {
+ "expression": "parent_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "widget_versions_widget_id_widgets_id_fk": {
+ "name": "widget_versions_widget_id_widgets_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "widgets",
+ "columnsFrom": ["widget_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_versions_user_id_users_id_fk": {
+ "name": "widget_versions_user_id_users_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_versions_workspace_id_workspaces_id_fk": {
+ "name": "widget_versions_workspace_id_workspaces_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widget_versions_published_by_user_id_users_id_fk": {
+ "name": "widget_versions_published_by_user_id_users_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "users",
+ "columnsFrom": ["published_by_user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "widget_versions_source_agent_id_agents_id_fk": {
+ "name": "widget_versions_source_agent_id_agents_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "agents",
+ "columnsFrom": ["source_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "widget_versions_source_topic_id_topics_id_fk": {
+ "name": "widget_versions_source_topic_id_topics_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "topics",
+ "columnsFrom": ["source_topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "widget_versions_parent_version_id_widget_versions_id_fk": {
+ "name": "widget_versions_parent_version_id_widget_versions_id_fk",
+ "tableFrom": "widget_versions",
+ "tableTo": "widget_versions",
+ "columnsFrom": ["parent_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.widgets": {
+ "name": "widgets",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_version_id": {
+ "name": "published_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "draft_version_id": {
+ "name": "draft_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_pattern": {
+ "name": "schedule_pattern",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_timezone": {
+ "name": "schedule_timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_run_id": {
+ "name": "last_run_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_run_status": {
+ "name": "last_run_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_run_error": {
+ "name": "last_run_error",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consecutive_failures": {
+ "name": "consecutive_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "latest_output": {
+ "name": "latest_output",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "latest_output_at": {
+ "name": "latest_output_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metric_id": {
+ "name": "metric_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'public'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accessed_at": {
+ "name": "accessed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "widgets_personal_idx": {
+ "name": "widgets_personal_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"widgets\".\"workspace_id\" IS NULL AND \"widgets\".\"project_id\" IS NULL AND \"widgets\".\"agent_id\" IS NULL AND \"widgets\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_workspace_idx": {
+ "name": "widgets_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"widgets\".\"workspace_id\" IS NOT NULL AND \"widgets\".\"project_id\" IS NULL AND \"widgets\".\"agent_id\" IS NULL AND \"widgets\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_project_idx": {
+ "name": "widgets_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"widgets\".\"project_id\" IS NOT NULL AND \"widgets\".\"agent_id\" IS NULL AND \"widgets\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_agent_idx": {
+ "name": "widgets_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"widgets\".\"agent_id\" IS NOT NULL AND \"widgets\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_due_idx": {
+ "name": "widgets_due_idx",
+ "columns": [
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"widgets\".\"next_run_at\" IS NOT NULL AND \"widgets\".\"schedule_pattern\" IS NOT NULL AND \"widgets\".\"published_version_id\" IS NOT NULL AND \"widgets\".\"is_deleted\" IS NOT TRUE",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_user_id_idx": {
+ "name": "widgets_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_workspace_id_idx": {
+ "name": "widgets_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_published_version_id_idx": {
+ "name": "widgets_published_version_id_idx",
+ "columns": [
+ {
+ "expression": "published_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_draft_version_id_idx": {
+ "name": "widgets_draft_version_id_idx",
+ "columns": [
+ {
+ "expression": "draft_version_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "widgets_metric_id_idx": {
+ "name": "widgets_metric_id_idx",
+ "columns": [
+ {
+ "expression": "metric_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "widgets_user_id_users_id_fk": {
+ "name": "widgets_user_id_users_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widgets_workspace_id_workspaces_id_fk": {
+ "name": "widgets_workspace_id_workspaces_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widgets_project_id_projects_id_fk": {
+ "name": "widgets_project_id_projects_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "projects",
+ "columnsFrom": ["project_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widgets_agent_id_agents_id_fk": {
+ "name": "widgets_agent_id_agents_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "widgets_published_version_id_widget_versions_id_fk": {
+ "name": "widgets_published_version_id_widget_versions_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "widget_versions",
+ "columnsFrom": ["published_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "widgets_draft_version_id_widget_versions_id_fk": {
+ "name": "widgets_draft_version_id_widget_versions_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "widget_versions",
+ "columnsFrom": ["draft_version_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "widgets_metric_id_metrics_id_fk": {
+ "name": "widgets_metric_id_metrics_id_fk",
+ "tableFrom": "widgets",
+ "tableTo": "metrics",
+ "columnsFrom": ["metric_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.work_versions": {
+ "name": "work_versions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "work_id": {
+ "name": "work_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "change_type": {
+ "name": "change_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_name": {
+ "name": "tool_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_identifier": {
+ "name": "tool_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "topic_id": {
+ "name": "topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "root_operation_id": {
+ "name": "root_operation_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cumulative_cost": {
+ "name": "cumulative_cost",
+ "type": "numeric(20, 6)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cumulative_usage": {
+ "name": "cumulative_usage",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "work_versions_work_id_version_unique": {
+ "name": "work_versions_work_id_version_unique",
+ "columns": [
+ {
+ "expression": "work_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_work_id_tool_call_id_unique": {
+ "name": "work_versions_work_id_tool_call_id_unique",
+ "columns": [
+ {
+ "expression": "work_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_call_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"work_versions\".\"tool_call_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_thread_id_idx": {
+ "name": "work_versions_thread_id_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_message_id_idx": {
+ "name": "work_versions_message_id_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_agent_id_idx": {
+ "name": "work_versions_agent_id_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_root_operation_created_at_idx": {
+ "name": "work_versions_root_operation_created_at_idx",
+ "columns": [
+ {
+ "expression": "root_operation_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_topic_created_at_idx": {
+ "name": "work_versions_topic_created_at_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "work_versions_topic_thread_created_at_idx": {
+ "name": "work_versions_topic_thread_created_at_idx",
+ "columns": [
+ {
+ "expression": "topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "work_versions_work_id_works_id_fk": {
+ "name": "work_versions_work_id_works_id_fk",
+ "tableFrom": "work_versions",
+ "tableTo": "works",
+ "columnsFrom": ["work_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "work_versions_topic_id_topics_id_fk": {
+ "name": "work_versions_topic_id_topics_id_fk",
+ "tableFrom": "work_versions",
+ "tableTo": "topics",
+ "columnsFrom": ["topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "work_versions_thread_id_threads_id_fk": {
+ "name": "work_versions_thread_id_threads_id_fk",
+ "tableFrom": "work_versions",
+ "tableTo": "threads",
+ "columnsFrom": ["thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "work_versions_message_id_messages_id_fk": {
+ "name": "work_versions_message_id_messages_id_fk",
+ "tableFrom": "work_versions",
+ "tableTo": "messages",
+ "columnsFrom": ["message_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "work_versions_agent_id_agents_id_fk": {
+ "name": "work_versions_agent_id_agents_id_fk",
+ "tableFrom": "work_versions",
+ "tableTo": "agents",
+ "columnsFrom": ["agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.works": {
+ "name": "works",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "current_version_id": {
+ "name": "current_version_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_name": {
+ "name": "tool_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_identifier": {
+ "name": "tool_identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin_topic_id": {
+ "name": "origin_topic_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "origin_thread_id": {
+ "name": "origin_thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "origin_agent_id": {
+ "name": "origin_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "is_deleted": {
+ "name": "is_deleted",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "works_resource_user_scope_unique": {
+ "name": "works_resource_user_scope_unique",
+ "columns": [
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "COALESCE((metadata -> 'agentShare' ->> 'topicId'), '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"works\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_resource_workspace_scope_unique": {
+ "name": "works_resource_workspace_scope_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "COALESCE((metadata -> 'agentShare' ->> 'topicId'), '')",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"works\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_user_id_idx": {
+ "name": "works_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_workspace_id_idx": {
+ "name": "works_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_workspace_visibility_idx": {
+ "name": "works_workspace_visibility_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_user_updated_at_id_idx": {
+ "name": "works_user_updated_at_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"works\".\"workspace_id\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_workspace_updated_at_id_idx": {
+ "name": "works_workspace_updated_at_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"works\".\"workspace_id\" is not null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_origin_topic_id_idx": {
+ "name": "works_origin_topic_id_idx",
+ "columns": [
+ {
+ "expression": "origin_topic_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_origin_thread_id_idx": {
+ "name": "works_origin_thread_id_idx",
+ "columns": [
+ {
+ "expression": "origin_thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "works_origin_agent_id_idx": {
+ "name": "works_origin_agent_id_idx",
+ "columns": [
+ {
+ "expression": "origin_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "works_origin_topic_id_topics_id_fk": {
+ "name": "works_origin_topic_id_topics_id_fk",
+ "tableFrom": "works",
+ "tableTo": "topics",
+ "columnsFrom": ["origin_topic_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "works_origin_thread_id_threads_id_fk": {
+ "name": "works_origin_thread_id_threads_id_fk",
+ "tableFrom": "works",
+ "tableTo": "threads",
+ "columnsFrom": ["origin_thread_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "works_origin_agent_id_agents_id_fk": {
+ "name": "works_origin_agent_id_agents_id_fk",
+ "tableFrom": "works",
+ "tableTo": "agents",
+ "columnsFrom": ["origin_agent_id"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "works_user_id_users_id_fk": {
+ "name": "works_user_id_users_id_fk",
+ "tableFrom": "works",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "works_workspace_id_workspaces_id_fk": {
+ "name": "works_workspace_id_workspaces_id_fk",
+ "tableFrom": "works",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_audit_logs": {
+ "name": "workspace_audit_logs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_type": {
+ "name": "resource_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_audit_logs_workspace_id_idx": {
+ "name": "workspace_audit_logs_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_audit_logs_action_idx": {
+ "name": "workspace_audit_logs_action_idx",
+ "columns": [
+ {
+ "expression": "action",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_audit_logs_created_at_idx": {
+ "name": "workspace_audit_logs_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_audit_logs_workspace_id_workspaces_id_fk": {
+ "name": "workspace_audit_logs_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_audit_logs",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_invitations": {
+ "name": "workspace_invitations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "inviter_id": {
+ "name": "inviter_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_invitations_workspace_id_idx": {
+ "name": "workspace_invitations_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invitations_inviter_id_idx": {
+ "name": "workspace_invitations_inviter_id_idx",
+ "columns": [
+ {
+ "expression": "inviter_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invitations_email_idx": {
+ "name": "workspace_invitations_email_idx",
+ "columns": [
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_invitations_token_idx": {
+ "name": "workspace_invitations_token_idx",
+ "columns": [
+ {
+ "expression": "token",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_invitations_workspace_id_workspaces_id_fk": {
+ "name": "workspace_invitations_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_invitations",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_invitations_inviter_id_users_id_fk": {
+ "name": "workspace_invitations_inviter_id_users_id_fk",
+ "tableFrom": "workspace_invitations",
+ "tableTo": "users",
+ "columnsFrom": ["inviter_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_invitations_token_unique": {
+ "name": "workspace_invitations_token_unique",
+ "nullsNotDistinct": false,
+ "columns": ["token"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_members": {
+ "name": "workspace_members",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "joined_at": {
+ "name": "joined_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "workspace_members_user_id_idx": {
+ "name": "workspace_members_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_members_unique_active_owner_idx": {
+ "name": "workspace_members_unique_active_owner_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"workspace_members\".\"role\" = 'owner' AND \"workspace_members\".\"deleted_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_members_user_id_users_id_fk": {
+ "name": "workspace_members_user_id_users_id_fk",
+ "tableFrom": "workspace_members",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_members_workspace_id_user_id_pk": {
+ "name": "workspace_members_workspace_id_user_id_pk",
+ "columns": ["workspace_id", "user_id"]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_team_members": {
+ "name": "workspace_team_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_team_members_team_user_unique": {
+ "name": "workspace_team_members_team_user_unique",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_team_members_workspace_user_idx": {
+ "name": "workspace_team_members_workspace_user_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_team_members_user_id_idx": {
+ "name": "workspace_team_members_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_team_members_workspace_id_workspaces_id_fk": {
+ "name": "workspace_team_members_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_team_members",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_team_members_user_id_users_id_fk": {
+ "name": "workspace_team_members_user_id_users_id_fk",
+ "tableFrom": "workspace_team_members",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_team_members_team_workspace_fk": {
+ "name": "workspace_team_members_team_workspace_fk",
+ "tableFrom": "workspace_team_members",
+ "tableTo": "workspace_teams",
+ "columnsFrom": ["team_id", "workspace_id"],
+ "columnsTo": ["id", "workspace_id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_teams": {
+ "name": "workspace_teams",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(1000)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_teams_workspace_identifier_unique": {
+ "name": "workspace_teams_workspace_identifier_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_teams_workspace_id_idx": {
+ "name": "workspace_teams_workspace_id_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_teams_created_by_idx": {
+ "name": "workspace_teams_created_by_idx",
+ "columns": [
+ {
+ "expression": "created_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_teams_workspace_id_workspaces_id_fk": {
+ "name": "workspace_teams_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_teams",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_teams_created_by_users_id_fk": {
+ "name": "workspace_teams_created_by_users_id_fk",
+ "tableFrom": "workspace_teams",
+ "tableTo": "users",
+ "columnsFrom": ["created_by"],
+ "columnsTo": ["id"],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "workspace_teams_id_workspace_unique": {
+ "name": "workspace_teams_id_workspace_unique",
+ "nullsNotDistinct": false,
+ "columns": ["id", "workspace_id"]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace_user_settings": {
+ "name": "workspace_user_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "preference": {
+ "name": "preference",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_user_settings_workspace_id_user_id_unique": {
+ "name": "workspace_user_settings_workspace_id_user_id_unique",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_user_settings_user_id_idx": {
+ "name": "workspace_user_settings_user_id_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_user_settings_workspace_id_workspaces_id_fk": {
+ "name": "workspace_user_settings_workspace_id_workspaces_id_fk",
+ "tableFrom": "workspace_user_settings",
+ "tableTo": "workspaces",
+ "columnsFrom": ["workspace_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_user_settings_user_id_users_id_fk": {
+ "name": "workspace_user_settings_user_id_users_id_fk",
+ "tableFrom": "workspace_user_settings",
+ "tableTo": "users",
+ "columnsFrom": ["user_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspaces": {
+ "name": "workspaces",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(1000)",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "avatar": {
+ "name": "avatar",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "primary_owner_id": {
+ "name": "primary_owner_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'::jsonb"
+ },
+ "frozen": {
+ "name": "frozen",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "frozen_reason": {
+ "name": "frozen_reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frozen_at": {
+ "name": "frozen_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": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspaces_slug_idx": {
+ "name": "workspaces_slug_idx",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspaces_primary_owner_id_idx": {
+ "name": "workspaces_primary_owner_id_idx",
+ "columns": [
+ {
+ "expression": "primary_owner_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspaces_primary_owner_id_users_id_fk": {
+ "name": "workspaces_primary_owner_id_users_id_fk",
+ "tableFrom": "workspaces",
+ "tableTo": "users",
+ "columnsFrom": ["primary_owner_id"],
+ "columnsTo": ["id"],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "version": "7",
+ "views": {}
+}
diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json
index a165d494e5f..18f53f019dc 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1288,6 +1288,13 @@
"when": 1792606514901,
"tag": "0183_project_order_and_agent_signals",
"breakpoints": true
+ },
+ {
+ "idx": 184,
+ "version": "7",
+ "when": 1792830037847,
+ "tag": "0184_channel_tables",
+ "breakpoints": true
}
],
"version": "6"
diff --git a/packages/database/src/models/__tests__/channelIsolation.test.ts b/packages/database/src/models/__tests__/channelIsolation.test.ts
new file mode 100644
index 00000000000..0e5db18682a
--- /dev/null
+++ b/packages/database/src/models/__tests__/channelIsolation.test.ts
@@ -0,0 +1,120 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../core/getTestDB';
+import { ChannelExecutionRepository, ChannelRepository } from '../../repositories/channel';
+import {
+ createChannelFixture,
+ jobsOf,
+ lease,
+} from '../../repositories/channel/__tests__/testUtils';
+import { agentOperations, channelMessages, channels, topics } from '../../schemas';
+import { AgentOperationModel } from '../agentOperation';
+import { MessageModel } from '../message';
+import { TopicModel } from '../topic';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-boundary');
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const setup = async () => {
+ const repository = new ChannelRepository(db, fixture.ownerId);
+ const { channel } = await repository.create({ title: 'Personal channel' });
+ const agent = await fixture.addAgent(channel.id, 'Agent');
+ const publicMessage = await repository.send(channel.id, {
+ content: 'Public request',
+ mentions: [agent.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, publicMessage.id);
+ const execution = new ChannelExecutionRepository(db);
+ const claim = (await execution.claim(channel.id, job.id, lease))!;
+ const runtime = new MessageModel(db, fixture.ownerId);
+ const internal = await runtime.create({
+ content: 'Internal execution',
+ role: 'assistant',
+ agentId: agent.agentId!,
+ topicId: claim.topic.id,
+ });
+ return { agent, channel, claim, execution, internal, publicMessage, runtime };
+};
+
+describe('Channel source and ordinary conversation boundaries', () => {
+ it('uses ordinary topic, message and operation APIs for authorized execution details', async () => {
+ const state = await setup();
+ expect(await state.runtime.findById(state.internal.id)).toMatchObject({
+ content: 'Internal execution',
+ });
+ expect(await new TopicModel(db, fixture.ownerId).findById(state.claim.topic.id)).toMatchObject({
+ agentId: state.agent.agentId,
+ trigger: 'channel',
+ userId: fixture.ownerId,
+ });
+ expect(
+ await new AgentOperationModel(db, fixture.ownerId).findById(state.claim.job.operationId!),
+ ).toMatchObject({ topicId: state.claim.topic.id });
+ expect(await state.runtime.findById(state.publicMessage.id)).toBeUndefined();
+ expect(
+ (await state.execution.input(state.channel.id, state.claim.job.id)).map((m) => m.content),
+ ).toEqual(['Public request']);
+ });
+
+ it('does not grant conversation access through a Channel membership', async () => {
+ const state = await setup();
+ await fixture.addPerson(state.channel.id, fixture.memberId, 'member');
+ const other = new MessageModel(db, fixture.memberId);
+ expect(await other.findById(state.internal.id)).toBeUndefined();
+ expect(await other.update(state.internal.id, { content: 'forged' })).toEqual({
+ success: false,
+ });
+ expect(
+ await new TopicModel(db, fixture.memberId).findById(state.claim.topic.id),
+ ).toBeUndefined();
+ expect(
+ await new AgentOperationModel(db, fixture.memberId).findById(state.claim.job.operationId!),
+ ).toBeNull();
+ expect(
+ await new TopicModel(db, fixture.ownerId, fixture.workspaceId).findById(state.claim.topic.id),
+ ).toBeUndefined();
+ });
+
+ it('keeps public history after deleting an internal topic, and keeps execution history after deleting the Channel', async () => {
+ const state = await setup();
+ await db.delete(topics).where(eq(topics.id, state.claim.topic.id));
+ expect(
+ await db.select().from(channelMessages).where(eq(channelMessages.id, state.publicMessage.id)),
+ ).toHaveLength(1);
+ const next = await setup();
+ await db.delete(channels).where(eq(channels.id, next.channel.id));
+ expect(await next.runtime.findById(next.internal.id)).toBeDefined();
+ expect(await new TopicModel(db, fixture.ownerId).findById(next.claim.topic.id)).toBeDefined();
+ });
+
+ it('initializes a reserved operation only for the same principal, topic and Agent, without resurrecting completed work', async () => {
+ const state = await setup();
+ const params = {
+ agentId: state.agent.agentId,
+ operationId: state.claim.job.operationId!,
+ topicId: state.claim.topic.id,
+ };
+ const owner = new AgentOperationModel(db, fixture.ownerId);
+ const read = async () =>
+ (
+ await db.select().from(agentOperations).where(eq(agentOperations.id, params.operationId))
+ )[0];
+ await new AgentOperationModel(db, fixture.memberId).recordStart(params);
+ await new AgentOperationModel(db, fixture.ownerId, fixture.workspaceId).recordStart(params);
+ await owner.recordStart({ ...params, agentId: null });
+ const [otherTopic] = await db.insert(topics).values({ userId: fixture.ownerId }).returning();
+ await owner.recordStart({ ...params, topicId: otherTopic.id });
+ expect((await read()).status).toBe('idle');
+ await owner.recordStart({ ...params, maxSteps: 20 });
+ expect(await read()).toMatchObject({ status: 'running', maxSteps: 20 });
+ await owner.recordCompletion(params.operationId, { status: 'done', totalTokens: 123 });
+ await owner.recordStart(params);
+ expect(await read()).toMatchObject({ status: 'done', totalTokens: 123 });
+ });
+});
diff --git a/packages/database/src/models/__tests__/file.channelReferences.test.ts b/packages/database/src/models/__tests__/file.channelReferences.test.ts
new file mode 100644
index 00000000000..41724a323fd
--- /dev/null
+++ b/packages/database/src/models/__tests__/file.channelReferences.test.ts
@@ -0,0 +1,85 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../core/getTestDB';
+import { ChannelRepository } from '../../repositories/channel';
+import { channels, files, messages, messagesFiles, sessions, topics, users } from '../../schemas';
+import type { LobeChatDatabase } from '../../type';
+import { FileModel } from '../file';
+
+const serverDB: LobeChatDatabase = await getTestDB();
+
+const userId = 'file-channel-refs-user';
+const fileModel = new FileModel(serverDB, userId);
+
+beforeEach(async () => {
+ await serverDB.insert(users).values({ id: userId });
+});
+
+afterEach(async () => {
+ await serverDB.delete(channels).where(eq(channels.userId, userId));
+ await serverDB.delete(users).where(eq(users.id, userId));
+});
+
+const createFile = async (name: string) => {
+ const { id } = await fileModel.create({
+ fileType: 'text/plain',
+ name,
+ size: 1,
+ url: `files/${name}`,
+ });
+ return id;
+};
+
+/** Attaches the file to a message in the user's personal channel. */
+const attachInChannel = async (fileId: string) => {
+ const model = new ChannelRepository(serverDB, userId);
+ const { channel } = await model.create({ title: 'Channel' });
+ await model.send(channel.id, {
+ content: 'See attached',
+ fileIds: [fileId],
+ requestKey: 'req-1',
+ routing: 'fallback',
+ });
+};
+
+describe('FileModel channel message references', () => {
+ it('deleteUnreferenced keeps a file attached to a channel message', async () => {
+ // Channel attachments have their own relation; cleanup must still protect the file.
+ const id = await createFile('channel.txt');
+ await attachInChannel(id);
+
+ await expect(fileModel.deleteUnreferenced(id)).resolves.toBeUndefined();
+ await expect(serverDB.select().from(files).where(eq(files.id, id))).resolves.toHaveLength(1);
+ });
+
+ it('findDeletableFilesByTopicId keeps a topic file that a channel message also uses', async () => {
+ const [onlyInTopic, alsoInChannel] = [
+ await createFile('topic.txt'),
+ await createFile('shared.txt'),
+ ];
+ await serverDB.insert(sessions).values({ id: 'file-channel-refs-session', userId });
+ await serverDB
+ .insert(topics)
+ .values({ id: 'file-channel-refs-topic', sessionId: 'file-channel-refs-session', userId });
+ await serverDB.insert(messages).values({
+ id: 'file-channel-refs-msg',
+ role: 'user',
+ topicId: 'file-channel-refs-topic',
+ userId,
+ });
+ await serverDB.insert(messagesFiles).values([
+ { fileId: onlyInTopic, messageId: 'file-channel-refs-msg', userId },
+ { fileId: alsoInChannel, messageId: 'file-channel-refs-msg', userId },
+ ]);
+ await attachInChannel(alsoInChannel);
+
+ await expect(fileModel.findDeletableFilesByTopicId('file-channel-refs-topic')).resolves.toEqual(
+ [onlyInTopic],
+ );
+ await serverDB.delete(topics).where(eq(topics.id, 'file-channel-refs-topic'));
+ await fileModel.deleteUnreferenced(alsoInChannel);
+ expect(await serverDB.select().from(files).where(eq(files.id, alsoInChannel))).toHaveLength(1);
+ });
+});
diff --git a/packages/database/src/models/agentOperation.ts b/packages/database/src/models/agentOperation.ts
index f346fe2a2cf..27b99d1dad9 100644
--- a/packages/database/src/models/agentOperation.ts
+++ b/packages/database/src/models/agentOperation.ts
@@ -147,8 +147,7 @@ export class AgentOperationModel {
/**
* Insert the initial row when an operation is created. Idempotent via
- * `onConflictDoNothing` on the primary key so resumed operations don't
- * blow up on the second createOperation call.
+ * the primary key; only an idle reservation with the same identity may be initialized.
*/
async recordStart(params: RecordOperationStartParams): Promise<void> {
const values: NewAgentOperation = {
@@ -172,7 +171,22 @@ export class AgentOperationModel {
workspaceId: this.workspaceId ?? null,
};
- await this.db.insert(agentOperations).values(values).onConflictDoNothing();
+ // A trigger may reserve an idle operation before dispatch. Only the same execution
+ // identity may initialize it; duplicate starts never overwrite a running or terminal row.
+ await this.db
+ .insert(agentOperations)
+ .values(values)
+ .onConflictDoUpdate({
+ target: agentOperations.id,
+ set: values,
+ setWhere: and(
+ eq(agentOperations.status, 'idle'),
+ eq(agentOperations.userId, this.userId),
+ sql`${agentOperations.workspaceId} IS NOT DISTINCT FROM ${this.workspaceId ?? null}`,
+ sql`${agentOperations.topicId} IS NOT DISTINCT FROM ${params.topicId ?? null}`,
+ sql`${agentOperations.agentId} IS NOT DISTINCT FROM ${params.agentId ?? null}`,
+ ),
+ });
}
/**
diff --git a/packages/database/src/models/file.ts b/packages/database/src/models/file.ts
index 8f4717956e7..d7ed423d4ea 100644
--- a/packages/database/src/models/file.ts
+++ b/packages/database/src/models/file.ts
@@ -27,6 +27,7 @@ import type { FileItem, NewFile, NewGlobalFile } from '../schemas';
import {
agentsFiles,
asyncTasks,
+ channelMessageFiles,
chunks,
documentChunks,
documents,
@@ -264,7 +265,8 @@ export class FileModel {
/**
* Delete a transient upload only while no persisted content references it.
- * This also covers documents, knowledge bases, agents, generated media, TTS and evidence.
+ * This also covers documents, knowledge bases, agents, channel messages, generated media, TTS
+ * and evidence.
* Locking the file row serializes this cleanup with foreign-key inserts, so a late send either
* wins ownership and preserves the file or observes the deletion and fails atomically.
*
@@ -303,6 +305,12 @@ export class FileModel {
.where(eq(messagesFiles.fileId, id))
.limit(1);
if (messageReference) return;
+ const [channelReference] = await trx
+ .select({ id: channelMessageFiles.fileId })
+ .from(channelMessageFiles)
+ .where(eq(channelMessageFiles.fileId, id))
+ .limit(1);
+ if (channelReference) return;
const [sessionReference] = await trx
.select({ id: filesToSessions.fileId })
@@ -721,8 +729,9 @@ export class FileModel {
* Deleting a `files` row cascades to `messages_files` and `files_to_sessions`,
* so a file still referenced elsewhere would silently disappear from there.
* A candidate is therefore preserved (excluded) when it is still attached:
- * - to a message in another topic (or a message with no topic), or
- * - at the session level (`files_to_sessions`), which outlives a single topic.
+ * - to a message in another topic (or a message with no topic),
+ * - at the session level (`files_to_sessions`), which outlives a single topic, or
+ * - to a public Channel message (`channel_message_files`).
*
* Session-level files are likewise never returned, matching the behaviour
* documented on {@link findFilesToInitInSandbox}.
@@ -737,7 +746,7 @@ export class FileModel {
const candidateIds = candidates.map((row) => row.id);
if (candidateIds.length === 0) return [];
- const [messageRefsOutsideTopic, sessionRefs] = await Promise.all([
+ const [messageRefsOutsideTopic, sessionRefs, channelRefs] = await Promise.all([
// same file attached to a message in a different topic (or no topic)
this.db
.selectDistinct({ id: messagesFiles.fileId })
@@ -746,7 +755,6 @@ export class FileModel {
.where(
and(
inArray(messagesFiles.fileId, candidateIds),
- eq(messagesFiles.userId, this.userId),
or(ne(messages.topicId, topicId), isNull(messages.topicId)),
),
),
@@ -760,11 +768,16 @@ export class FileModel {
eq(filesToSessions.userId, this.userId),
),
),
+ this.db
+ .selectDistinct({ id: channelMessageFiles.fileId })
+ .from(channelMessageFiles)
+ .where(inArray(channelMessageFiles.fileId, candidateIds)),
]);
const referencedElsewhere = new Set<string>([
...messageRefsOutsideTopic.map((row) => row.id),
...sessionRefs.map((row) => row.id),
+ ...channelRefs.map((row) => row.id),
]);
return candidateIds.filter((id) => !referencedElsewhere.has(id));
diff --git a/packages/database/src/models/user.ts b/packages/database/src/models/user.ts
index e15124adb84..a0fd6b45c21 100644
--- a/packages/database/src/models/user.ts
+++ b/packages/database/src/models/user.ts
@@ -9,7 +9,7 @@ import type {
} from '@lobechat/types';
import { TRPCError } from '@trpc/server';
import dayjs from 'dayjs';
-import { and, asc, eq, gt, inArray, isNull, max, or, sql } from 'drizzle-orm';
+import { and, asc, eq, gt, inArray, isNotNull, isNull, max, or, sql } from 'drizzle-orm';
import type { PartialDeep } from 'type-fest';
import { merge } from '@/utils/merge';
@@ -18,6 +18,7 @@ import { today } from '@/utils/time';
import type { NewUser, UserItem, UserSettingsItem } from '../schemas';
import {
agents,
+ channels,
chatGroups,
goals,
messages,
@@ -576,6 +577,17 @@ export class UserModel {
// Purge share-visitor topics authored by this user under any creator.
await tx.delete(topics).where(eq(topics.senderId, id));
await applyRemainingTimeout();
+ // Personal channels and direct conversations belong to this user alone. Workspace groups
+ // outlive their creator: the user cascade only clears the channel's and member's `user_id`.
+ await tx
+ .delete(channels)
+ .where(
+ and(
+ eq(channels.userId, id),
+ or(isNull(channels.workspaceId), isNotNull(channels.agentId)),
+ ),
+ );
+ await applyRemainingTimeout();
const result = await tx.delete(users).where(eq(users.id, id));
if (deadline !== undefined && Date.now() >= deadline)
throw new Error('Account deletion transaction deadline exceeded');
diff --git a/packages/database/src/repositories/channel/README.md b/packages/database/src/repositories/channel/README.md
new file mode 100644
index 00000000000..d1b9836ea42
--- /dev/null
+++ b/packages/database/src/repositories/channel/README.md
@@ -0,0 +1,149 @@
+# Channel persistence boundary
+
+Channel owns a public collaboration timeline and triggers existing Agent conversations.
+This package provides the data contract; it does not activate Channel routers, runtime adapters,
+subscriptions or a details UI. Repository transactions lock the `channels` row before coordinating
+public messages, deliveries, topics and operations.
+
+## Storage
+
+| Responsibility | Storage |
+| ---------------------------------------------- | ------------------------------------------------------------------------------------- |
+| Membership, roles, routing, branches, ordering | Channel tables |
+| Conversation kind | `channels.agentId`: bound Agent for a direct conversation; NULL for a group |
+| Message sender | `channel_messages.userId` or `agentId`; never the requesting user on an Agent reply |
+| Public content and replies | `channel_messages.content`; independent IDs |
+| Public attachments | `channel_message_files`, with sender-checked file references and order |
+| Internal conversation | Ordinary `topics` and `messages`, with the actual Agent and requester |
+| CLI resume handle | Topic `metadata.heteroSessionId` (not a database topic ID) |
+| Execution status, errors, usage, traces | One ordinary `agent_operations` row per claimed job |
+| Source relation and coordination | `channel_jobs.topicId` / `operationId`, input window, FIFO, lease, locks, publication |
+
+There is no `channel_id` on ordinary messages, topics or operations, no public Channel topic, and
+no separate Channel session/run/runtime-message store. `trigger='channel'` records the origin of
+an ordinary conversation/execution. The job points to it from the source side.
+
+A direct conversation binds `channels.userId` (its human participant) and `channels.agentId`.
+`ChannelRepository.create({ agentId, title })` checks Agent access, creates both members atomically,
+and requires private visibility. It opens the default conversation: a unique index on Agent, person
+and scope keeps one per pair, so repeated or concurrent calls return the existing channel. The scope
+is part of the key because a transferred Agent starts a new conversation in its new workspace.
+Only that human participant can access it, even if another
+membership is accidentally granted. It accepts no additional Agent members and routes unmentioned
+messages directly to the bound Agent. Group channels leave `agentId` NULL, including groups with
+only one Agent. Deleting a bound Agent cascades its direct conversations and their public history.
+
+Group history survives deletion of an author or Agent. Message sender references use `SET NULL`;
+new writes require exactly one actual sender. Human requests have `userId`, Agent replies have
+`agentId`; the database forbids mixing these roles. Both references can be NULL only in retained
+history through repository writes. The existing `routingStatus='reply'` identifies Agent replies
+after deletion; other statuses are human requests. Context authors expose the actual user/Agent ID
+(or NULL after deletion) and resolve names from those entities, with deleted-author fallbacks.
+Member IDs still identify mentions, Thread followers, requester permissions and execution environments.
+The claimed manifest freezes the replying Agent ID so rebinding a member cannot change authorship.
+
+Member, grant, message and job IDs are database-generated UUIDs; message references use UUID
+columns as well. Agent members reference `agents.id`; deletion clears that reference and blocks
+new claims, retaining group history. Optional `channels.project_id` is cleared on project deletion.
+Project association does not grant Channel access. Personal channels and direct conversations,
+including workspace ones, are removed with their owner; workspace groups retain their public history
+if the creator leaves or deletes their account.
+
+`ChannelRepository.addAgent` requires an admin and a usable Agent in the current scope. The
+nullable reference exists for deletion history, not for creating an unbound Agent member. The
+member's `config` contains only the Channel device, device owner and working directory. Its name
+and description are Channel routing/execution labels; message author names come from the actual sender.
+
+Every claim rechecks the actual requester's Agent access and reads the Agent's current settings.
+Configuration uses the same merge function as AgentService: system defaults, server defaults,
+personal defaults (personal scope only), then the Agent. Workers must supply trusted
+`getServerDefaultAgentConfig()` output in `serverDefaultAgentConfig` (`{}` when unconfigured).
+The job's `executionConfig` freezes those settings, the Agent runtime and the Channel environment.
+Updating Agent settings affects the next claim, including already queued requests; it never
+rewrites an earlier job snapshot. A private, trashed, deleted or moved Agent fails the requester
+access check before any topic or operation is created.
+
+## Topic continuation
+
+Every claim reserves a new operation, but normally continues the previous topic for the same
+Channel Agent member, branch and requesting member. Requester isolation prevents resuming another
+person's credentials or internal context. The last claimed delivery (ordered by `claimedAt`, not request sequence) must have accepted input,
+finished successfully and released its writer without revocation/isolation. Publication may still
+be pending. Its Agent and execution configuration must still match, and its
+topic must exist in the same user/workspace scope and not be trashed.
+
+Like the Discord bridge, the main timeline starts a new topic when the previous topic's
+`updatedAt` is more than four hours old. This is checked when the next request arrives; it is not a
+timer and does not delete old topics. Channel Threads keep their topic despite idle time. A
+late-routed request older than the previous input cutoff starts a new topic instead of inheriting
+later context. Failed/unknown executions, changed environments and unavailable topics also start
+afresh. An adapter's explicit “new conversation” feature is outside this foundation.
+
+A fresh topic receives the full branch through the triggering request: a Thread gets the main
+prefix through its root plus its own messages. Continuation receives only public messages in
+`(manifest.afterSequence, manifest.cutoffSequence]`. Its own published answers are excluded because
+they already exist in the ordinary transcript, including answers published after another request
+was queued. Other participants' messages remain new input. The manifest freezes bounds and the
+execution scope, not a duplicate transcript; later messages cannot change an earlier input.
+Author names and attachment availability are resolved at read time.
+
+## Access and runtime integration
+
+- `ChannelRepository` checks membership, role and workspace scope. Future routers must also
+ authenticate active workspace membership. Agent configuration, execution permission and device
+ grants must be authorized before dispatch; a Channel membership is not Agent authorization.
+- Ordinary models keep their existing user/workspace authorization semantics. There are no
+ Channel-specific constructors, exclusions from search/memory/sharing, or blanket rejection of
+ Channel-triggered operations. Public Channel messages cannot be read through ordinary chat APIs
+ because they live in a different table. Workspace model scope alone is not an Agent permission
+ check: the eventual details endpoint must authorize the Agent/topic using the existing access
+ layer before opening normal topic details. This PR does not introduce that endpoint or grant.
+- The public timeline includes only posted messages and selected final replies. Tool calls,
+ intermediate outputs and reasoning remain in ordinary conversation storage. Opening details is
+ a separate authorized operation, not an expansion of the public timeline.
+- Read new input with `ChannelExecutionRepository.input(channelId, jobId)` and pass the claim's
+ `topic.id`, actual requester/Agent and `job.operationId` into the existing runtime. Persist the
+ internal transcript with ordinary models; never copy all historical Channel input again when
+ continuing. CLI adapters resume from `topic.metadata.heteroSessionId`.
+- Dispatch with the job's frozen Agent settings and Channel environment, not `member.config` or
+ a fresh settings lookup. Device routing and working-directory overrides come from the Channel
+ environment whose grant and locks were checked, not the Agent's default device binding.
+ Knowledge and file contents still use the ordinary authorized runtime loaders; they are not
+ copied into this settings snapshot.
+- Call `recordStart` for the reserved idle operation before acknowledging dispatch. Only an exact
+ user/workspace/topic/Agent match may initialize it. Repeated starts cannot overwrite running or
+ terminal executions. The runtime remains responsible for normal topic activity updates.
+- Acknowledgement records native resume/turn IDs. Save the final answer once, then publish its
+ text to `channel_messages`; publication is idempotent and cannot publish a revoked delivery.
+ Public attachment uploads are authorized and locked before association. Generic file cleanup
+ preserves files still referenced by Channel messages.
+- Job status describes the Channel delivery; execution status/errors/usage live on its operation.
+ Operation completion is not proof that a device process ended. Only `releaseWriter` after
+ confirmed termination, or a trusted `notSubmitted` failure, releases the writer. Isolation frees
+ the member but keeps the device/directory lock. Never retry an unknown delivery.
+- Existing hard-delete paths already reach Channel rows: Agent deletion (including trash purge,
+ session and group deletion) cascades direct conversations, `UserModel.deleteUser` removes
+ personal channels and direct conversations, and workspace deletion cascades every channel in it.
+ The storage cascade removes jobs and directory locks; it does not stop external processes.
+ Before Channel creation is exposed, these paths must stop active writers and confirm physical
+ termination first. This unactivated foundation does not provide that orchestration.
+- Deleting a Channel deletes its jobs/public history, not ordinary conversations or execution
+ records. Deleting a topic/operation clears the corresponding job reference; it does not delete
+ the Channel timeline or release an unconfirmed writer.
+
+## Migration and verification
+
+`0184_channel_tables` is the consolidated, unshipped PR migration regenerated from the final
+schema on top of 0183. It creates Channel tables and references existing Agents, topics,
+operations and files; it does not add columns or indexes to the ordinary chat tables. Defensive
+DDL permits replay of this exact schema, not conversion from earlier development-only versions.
+A separately deployed prototype needs an explicit inventory and conversion plan before cutover.
+The normal deployment migration runner applies this migration; no separate online index step is
+needed for existing chat tables.
+
+Focused integration tests cover storage separation, ordinary access boundaries, attachment
+retention, continuation/expiry, incremental input, routing, stops and writer locks. Run with PGlite
+and with PostgreSQL (`vitest.config.server.mts`); the two concurrent claim/sequence tests require
+real PostgreSQL row locking. No product acceptance surface exists yet: this PR remains an
+unactivated database/repository foundation. Runtime and UI integration will require acceptance
+when delivered.
diff --git a/packages/database/src/repositories/channel/__tests__/access.test.ts b/packages/database/src/repositories/channel/__tests__/access.test.ts
new file mode 100644
index 00000000000..aa5e54592de
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/access.test.ts
@@ -0,0 +1,269 @@
+// @vitest-environment node
+import { eq, inArray, sql } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { UserModel } from '../../../models/user';
+import { agents, channelMembers, channels, users, workspaces } from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { ChannelError, ChannelRepository } from '..';
+
+const serverDB: LobeChatDatabase = await getTestDB();
+// Two concurrent transactions need separate connections; PGlite runs them one after another.
+const isServerDB = process.env.TEST_SERVER_DB === '1';
+
+const ownerId = 'channel-model-owner';
+const memberId = 'channel-model-member';
+const outsiderId = 'channel-model-outsider';
+const workspaceId = 'channel-model-workspace';
+
+const addPerson = async (channelId: string, userId: string, role: 'admin' | 'member') =>
+ serverDB.insert(channelMembers).values({ actorType: 'user', channelId, role, userId });
+
+/** Resolves once some session in this database is waiting on a row lock. */
+const waitForLockWaiter = async () => {
+ for (let attempt = 0; attempt < 100; attempt++) {
+ const { rows } = await serverDB.execute<{ waiting: number }>(
+ sql`SELECT count(*)::int AS waiting FROM pg_stat_activity
+ WHERE datname = current_database() AND wait_event_type = 'Lock'`,
+ );
+ if (rows[0]?.waiting) return;
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ }
+ throw new Error('No transaction started waiting for the channel lock');
+};
+
+beforeEach(async () => {
+ await serverDB.insert(users).values([{ id: ownerId }, { id: memberId }, { id: outsiderId }]);
+ await serverDB
+ .insert(workspaces)
+ .values({ id: workspaceId, name: 'Workspace', primaryOwnerId: ownerId, slug: workspaceId });
+});
+
+afterEach(async () => {
+ await serverDB.delete(workspaces).where(eq(workspaces.id, workspaceId));
+ await serverDB.delete(users).where(inArray(users.id, [ownerId, memberId, outsiderId]));
+});
+
+describe('ChannelRepository', () => {
+ describe('create', () => {
+ it('creates a personal channel with the caller as owner member', async () => {
+ const { channel, member } = await new ChannelRepository(serverDB, ownerId).create({
+ title: 'Personal',
+ });
+
+ expect(channel).toMatchObject({
+ userId: ownerId,
+ visibility: 'private',
+ workspaceId: null,
+ });
+ expect(member).toMatchObject({
+ actorType: 'user',
+ channelId: channel.id,
+ lastReadSequence: 0,
+ role: 'owner',
+ userId: ownerId,
+ });
+ expect(channel.id).toMatch(/^chn_[\dA-Za-z]{12}$/);
+ expect(member.id).toMatch(
+ /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/,
+ );
+ });
+
+ it('creates a workspace channel and treats a blank workspace as personal', async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ visibility: 'public',
+ });
+ const { channel: personal } = await new ChannelRepository(serverDB, ownerId, ' ').create({
+ title: 'Blank scope',
+ });
+
+ expect(channel).toMatchObject({ visibility: 'public', workspaceId });
+ expect(personal.workspaceId).toBeNull();
+ });
+ });
+
+ describe('membership-based access', () => {
+ it('lets every active member read the channel, not just its creator', async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ });
+ await addPerson(channel.id, memberId, 'member');
+
+ const asMember = new ChannelRepository(serverDB, memberId, workspaceId);
+ expect((await asMember.findAccess(channel.id))?.member.role).toBe('member');
+ expect((await asMember.list()).map((item) => item.id)).toEqual([channel.id]);
+
+ const asOutsider = new ChannelRepository(serverDB, outsiderId, workspaceId);
+ expect(await asOutsider.findAccess(channel.id)).toBeUndefined();
+ expect(await asOutsider.list()).toEqual([]);
+ });
+
+ it('hides channels from members who left and from other scopes', async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ });
+ await addPerson(channel.id, memberId, 'member');
+ await serverDB
+ .update(channelMembers)
+ .set({ active: false })
+ .where(eq(channelMembers.userId, memberId));
+
+ expect(
+ await new ChannelRepository(serverDB, memberId, workspaceId).findAccess(channel.id),
+ ).toBe(undefined);
+ expect(await new ChannelRepository(serverDB, ownerId).findAccess(channel.id)).toBeUndefined();
+ expect(await new ChannelRepository(serverDB, ownerId).list()).toEqual([]);
+ });
+
+ it('omits archived channels from the list', async () => {
+ const model = new ChannelRepository(serverDB, ownerId);
+ const { channel } = await model.create({ title: 'Archived' });
+ await serverDB.update(channels).set({ archived: true }).where(eq(channels.id, channel.id));
+
+ expect(await model.list()).toEqual([]);
+ });
+ });
+
+ describe('write', () => {
+ it('runs the mutation under the channel lock for a member with enough role', async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ });
+ await addPerson(channel.id, memberId, 'admin');
+
+ const title = await new ChannelRepository(serverDB, memberId, workspaceId).write(
+ channel.id,
+ async (tx, access) => {
+ await tx.update(channels).set({ title: 'Renamed' }).where(eq(channels.id, channel.id));
+ return access.channel.title;
+ },
+ { minRole: 'admin' },
+ );
+
+ const [renamed] = await serverDB.select().from(channels).where(eq(channels.id, channel.id));
+ expect(title).toBe('Team');
+ expect(renamed.title).toBe('Renamed');
+ });
+
+ it('rolls back mutations when the write callback fails', async () => {
+ const model = new ChannelRepository(serverDB, ownerId);
+ const { channel } = await model.create({ title: 'Personal' });
+
+ await expect(
+ model.write(channel.id, async (tx) => {
+ await tx
+ .update(channels)
+ .set({ title: 'Uncommitted' })
+ .where(eq(channels.id, channel.id));
+ throw new Error('rolled back');
+ }),
+ ).rejects.toThrow('rolled back');
+ expect((await model.findAccess(channel.id))?.channel.title).toBe('Personal');
+ });
+
+ it('rejects outsiders, insufficient roles and archived channels', async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ });
+ await addPerson(channel.id, memberId, 'member');
+ const noop = async () => undefined;
+
+ await expect(
+ new ChannelRepository(serverDB, outsiderId, workspaceId).write(channel.id, noop),
+ ).rejects.toMatchObject({ code: 'NOT_FOUND' });
+ await expect(
+ new ChannelRepository(serverDB, memberId, workspaceId).write(channel.id, noop, {
+ minRole: 'admin',
+ }),
+ ).rejects.toBeInstanceOf(ChannelError);
+
+ await serverDB.update(channels).set({ archived: true }).where(eq(channels.id, channel.id));
+ const asOwner = new ChannelRepository(serverDB, ownerId, workspaceId);
+ await expect(asOwner.write(channel.id, noop)).rejects.toMatchObject({ code: 'CONFLICT' });
+ await expect(
+ asOwner.write(channel.id, async () => 'restored', { allowArchived: true }),
+ ).resolves.toBe('restored');
+ });
+
+ it.skipIf(!isServerDB)(
+ 'checks membership as committed by the previous lock holder',
+ async () => {
+ const { channel } = await new ChannelRepository(serverDB, ownerId, workspaceId).create({
+ title: 'Team',
+ });
+ await addPerson(channel.id, memberId, 'admin');
+
+ let removed!: () => void;
+ const memberRemoved = new Promise<void>((resolve) => (removed = resolve));
+ let release!: () => void;
+ const released = new Promise<void>((resolve) => (release = resolve));
+ const removal = new ChannelRepository(serverDB, ownerId, workspaceId).write(
+ channel.id,
+ async (tx) => {
+ await tx
+ .update(channelMembers)
+ .set({ active: false })
+ .where(eq(channelMembers.userId, memberId));
+ removed();
+ await released;
+ },
+ );
+
+ await memberRemoved;
+ const staleWrite = new ChannelRepository(serverDB, memberId, workspaceId).write(
+ channel.id,
+ async () => 'wrote',
+ { minRole: 'admin' },
+ );
+ // Settle the promise early so a rejection is never reported as unhandled.
+ const staleResult = staleWrite.then(
+ () => 'wrote',
+ (error: ChannelError) => error.code,
+ );
+ await waitForLockWaiter();
+ release();
+ await removal;
+
+ expect(await staleResult).toBe('NOT_FOUND');
+ },
+ );
+ });
+
+ describe('account deletion', () => {
+ it('deletes personal channels and direct conversations, keeping workspace groups without a creator', async () => {
+ const { channel: personal } = await new ChannelRepository(serverDB, memberId).create({
+ title: 'Personal',
+ });
+ // Owned by someone else, so the Agent cascade cannot hide a missing cleanup.
+ const [agent] = await serverDB
+ .insert(agents)
+ .values({ userId: ownerId, workspaceId })
+ .returning();
+ const { channel: direct } = await new ChannelRepository(
+ serverDB,
+ memberId,
+ workspaceId,
+ ).create({ agentId: agent.id, title: 'Direct' });
+ const { channel: team } = await new ChannelRepository(serverDB, memberId, workspaceId).create(
+ {
+ title: 'Team',
+ },
+ );
+ await addPerson(team.id, ownerId, 'member');
+
+ await UserModel.deleteUser(serverDB, memberId);
+
+ const remaining = await serverDB
+ .select()
+ .from(channels)
+ .where(inArray(channels.id, [personal.id, direct.id, team.id]));
+ expect(remaining).toEqual([expect.objectContaining({ userId: null, id: team.id })]);
+ expect(
+ (await new ChannelRepository(serverDB, ownerId, workspaceId).findAccess(team.id))?.channel
+ .id,
+ ).toBe(team.id);
+ });
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/agentConfig.test.ts b/packages/database/src/repositories/channel/__tests__/agentConfig.test.ts
new file mode 100644
index 00000000000..c39b262fa7a
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/agentConfig.test.ts
@@ -0,0 +1,205 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { agents, channelMembers, userSettings } from '../../../schemas';
+import { ChannelExecutionRepository, ChannelRepository } from '..';
+import {
+ createChannelFixture,
+ deviceConfig,
+ jobById,
+ jobsOf,
+ lease,
+ operationById,
+} from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-agent-config');
+const execution = new ChannelExecutionRepository(db);
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+describe('Channel Agent configuration', () => {
+ it.each(['codex', 'claude-code'])('preserves the legacy model-only %s runtime', async (model) => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Legacy Agent');
+ await db
+ .update(agents)
+ .set({ model, agencyConfig: null })
+ .where(eq(agents.id, member.agentId!));
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Request',
+ mentions: [member.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, message.id);
+ const claim = (await execution.claim(team.channel.id, job.id, lease))!;
+ expect(claim.job.executionConfig?.runtime).toBe(model);
+ });
+
+ it.each([false, true])('uses the Agent default layers (workspace=%s)', async (workspace) => {
+ await db.insert(userSettings).values({
+ id: fixture.ownerId,
+ defaultAgent: { config: { model: 'personal-model', provider: 'personal-provider' } },
+ });
+ const repository = new ChannelRepository(
+ db,
+ fixture.ownerId,
+ workspace ? fixture.workspaceId : undefined,
+ );
+ const { channel } = await repository.create({ title: 'Defaults' });
+ const [agent] = await db
+ .insert(agents)
+ .values({
+ userId: fixture.ownerId,
+ workspaceId: workspace ? fixture.workspaceId : null,
+ model: '',
+ provider: null,
+ systemRole: 'Agent instructions',
+ })
+ .returning();
+ const member = await repository.addAgent(channel.id, { agentId: agent.id });
+ const message = await repository.send(channel.id, {
+ content: 'Request',
+ mentions: [member.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, message.id);
+ const claim = (await execution.claim(channel.id, job.id, {
+ ...lease,
+ serverDefaultAgentConfig: {
+ model: 'server-model',
+ provider: 'server-provider',
+ systemRole: 'Server instructions',
+ },
+ }))!;
+ expect(claim.job.executionConfig).toMatchObject({
+ model: workspace ? 'server-model' : 'personal-model',
+ provider: workspace ? 'server-provider' : 'personal-provider',
+ systemRole: 'Agent instructions',
+ runtime: 'native',
+ });
+ });
+
+ it('keeps the Channel environment while ignoring a stale member configuration copy', async () => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(
+ team.channel.id,
+ 'Coder',
+ deviceConfig('/channel-directory'),
+ );
+ const oldCopy = {
+ ...member.config,
+ model: 'stale',
+ provider: 'stale',
+ runtime: 'native',
+ systemRole: 'Stale',
+ };
+ await db
+ .update(channelMembers)
+ .set({ config: oldCopy })
+ .where(eq(channelMembers.id, member.id));
+ await db
+ .update(agents)
+ .set({
+ model: 'current-model',
+ provider: 'current-provider',
+ systemRole: 'Current',
+ agencyConfig: { heterogeneousProvider: { type: 'claude-code' } },
+ })
+ .where(eq(agents.id, member.agentId!));
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Request',
+ mentions: [member.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, message.id);
+ const claim = (await execution.claim(team.channel.id, job.id, lease))!;
+ expect(claim.job.executionConfig).toMatchObject({
+ model: 'current-model',
+ provider: 'current-provider',
+ systemRole: 'Current',
+ runtime: 'claude-code',
+ deviceId: 'device-1',
+ workingDirectory: '/channel-directory',
+ });
+ expect(claim.job).toMatchObject({
+ deviceId: 'device-1',
+ workingDirectory: '/channel-directory',
+ });
+ });
+
+ it('reads the current Agent at claim time and preserves an earlier execution snapshot', async () => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Agent');
+ const send = async (requestKey: string) => {
+ const message = await team.asMember.send(team.channel.id, {
+ content: requestKey,
+ mentions: [member.id],
+ requestKey,
+ routing: 'fallback',
+ });
+ return (await jobsOf(db, message.id))[0];
+ };
+ const first = (await execution.claim(team.channel.id, (await send('first')).id, lease))!;
+ const queued = await send('queued before changing settings');
+ await db
+ .update(agents)
+ .set({
+ model: 'claude-sonnet-4',
+ provider: 'anthropic',
+ systemRole: 'Use the updated instructions',
+ })
+ .where(eq(agents.id, member.agentId!));
+ expect((await jobById(db, first.job.id)).executionConfig).toEqual(first.job.executionConfig);
+ await execution.accepted(team.channel.id, first.job.id, {});
+ await execution.saveDraft(team.channel.id, first.job.id, 'Done');
+ await execution.releaseWriter(team.channel.id, first.job.id);
+ const next = (await execution.claim(team.channel.id, queued.id, lease))!;
+ expect(next.job.executionConfig).toMatchObject({
+ model: 'claude-sonnet-4',
+ provider: 'anthropic',
+ systemRole: 'Use the updated instructions',
+ });
+ expect(await operationById(db, next.job.operationId)).toMatchObject({
+ model: 'claude-sonnet-4',
+ provider: 'anthropic',
+ });
+ expect(next.topic.id).not.toBe(first.topic.id);
+ });
+
+ it.each(['private', 'trashed', 'other scope'])(
+ 'blocks a queued request after its Agent becomes %s',
+ async (reason) => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Agent');
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Request',
+ mentions: [member.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, message.id);
+ await db
+ .update(agents)
+ .set(
+ reason === 'private'
+ ? { visibility: 'private' }
+ : reason === 'trashed'
+ ? { isDeleted: true, deletedAt: new Date() }
+ : { workspaceId: null },
+ )
+ .where(eq(agents.id, member.agentId!));
+ expect(await execution.claim(team.channel.id, job.id, lease)).toBeNull();
+ expect(await jobById(db, job.id)).toMatchObject({
+ blockedCode: 'unavailable',
+ operationId: null,
+ topicId: null,
+ });
+ },
+ );
+});
diff --git a/packages/database/src/repositories/channel/__tests__/agentMember.test.ts b/packages/database/src/repositories/channel/__tests__/agentMember.test.ts
new file mode 100644
index 00000000000..987e1cc5d2c
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/agentMember.test.ts
@@ -0,0 +1,111 @@
+// @vitest-environment node
+import { and, eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { agents, channelMembers } from '../../../schemas';
+import { ChannelExecutionRepository, ChannelRepository } from '..';
+import { createChannelFixture, jobsOf, lease } from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-agent-member');
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+describe('adding an Agent to a Channel', () => {
+ it.each(['empty', 'missing', 'private', 'trashed', 'personal', 'other workspace'])(
+ 'rejects an %s or inaccessible reference without creating a member',
+ async (reason) => {
+ const team = await fixture.createTeamChannel();
+ const [agent] = await db
+ .insert(agents)
+ .values({
+ userId: fixture.memberId,
+ workspaceId: reason === 'personal' ? null : fixture.workspaceId,
+ visibility: reason === 'private' ? 'private' : 'public',
+ isDeleted: reason === 'trashed',
+ })
+ .returning();
+ const repository =
+ reason === 'other workspace' ? new ChannelRepository(db, fixture.ownerId) : team.asOwner;
+ const channel =
+ reason === 'other workspace'
+ ? (await repository.create({ title: 'Personal' })).channel
+ : team.channel;
+ const agentId = reason === 'empty' ? ' ' : reason === 'missing' ? 'missing' : agent.id;
+ await expect(repository.addAgent(channel.id, { agentId })).rejects.toMatchObject({
+ code: reason === 'empty' ? 'BAD_REQUEST' : 'NOT_FOUND',
+ });
+ expect(
+ await db
+ .select()
+ .from(channelMembers)
+ .where(
+ and(eq(channelMembers.channelId, channel.id), eq(channelMembers.actorType, 'agent')),
+ ),
+ ).toHaveLength(0);
+ },
+ );
+
+ it('requires a Channel admin and accepts another workspace member’s public Agent', async () => {
+ const team = await fixture.createTeamChannel();
+ const [agent] = await db
+ .insert(agents)
+ .values({
+ name: 'Current Agent name',
+ userId: fixture.memberId,
+ workspaceId: fixture.workspaceId,
+ })
+ .returning();
+ await expect(
+ team.asMember.addAgent(team.channel.id, { agentId: agent.id }),
+ ).rejects.toMatchObject({ code: 'FORBIDDEN' });
+ const added = await team.asOwner.addAgent(team.channel.id, { agentId: agent.id });
+ expect(added).toMatchObject({ agentId: agent.id, config: {}, name: 'Current Agent name' });
+ });
+
+ it('permits an owner’s private Agent but checks the actual requester again at claim', async () => {
+ const team = await fixture.createTeamChannel();
+ const [agent] = await db
+ .insert(agents)
+ .values({
+ userId: fixture.ownerId,
+ workspaceId: fixture.workspaceId,
+ visibility: 'private',
+ })
+ .returning();
+ const added = await team.asOwner.addAgent(team.channel.id, { agentId: agent.id });
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Request',
+ mentions: [added.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ const [job] = await jobsOf(db, message.id);
+ expect(
+ await new ChannelExecutionRepository(db).claim(team.channel.id, job.id, lease),
+ ).toBeNull();
+ });
+
+ it('keeps the member reference and public history after Agent deletion', async () => {
+ const team = await fixture.createTeamChannel();
+ const added = await fixture.addAgent(team.channel.id, 'Historical name');
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Request',
+ mentions: [added.id],
+ requestKey: 'request',
+ routing: 'fallback',
+ });
+ await db.delete(agents).where(eq(agents.id, added.agentId!));
+ const [retained] = await db
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.id, added.id));
+ expect(retained).toMatchObject({ agentId: null, name: 'Historical name' });
+ const [job] = await jobsOf(db, message.id);
+ expect(job.messageId).toBe(message.id);
+ expect(
+ await new ChannelExecutionRepository(db).claim(team.channel.id, job.id, lease),
+ ).toBeNull();
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/attachments.test.ts b/packages/database/src/repositories/channel/__tests__/attachments.test.ts
new file mode 100644
index 00000000000..f6d000525ca
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/attachments.test.ts
@@ -0,0 +1,85 @@
+// @vitest-environment node
+import { asc, eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { channelMessageFiles, files } from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { ChannelExecutionRepository } from '..';
+import { createChannelFixture, jobsOf, lease } from './testUtils';
+
+const db: LobeChatDatabase = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-attachments');
+const execution = new ChannelExecutionRepository(db);
+
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const createFile = async (name: string) => {
+ const [file] = await db
+ .insert(files)
+ .values({
+ fileType: 'text/plain',
+ name,
+ size: 1,
+ url: `files/${name}`,
+ userId: fixture.memberId,
+ workspaceId: fixture.workspaceId,
+ })
+ .returning();
+ return file.id;
+};
+
+const attachmentsOf = async (messageId: string) => {
+ const rows = await db
+ .select({ fileId: channelMessageFiles.fileId })
+ .from(channelMessageFiles)
+ .where(eq(channelMessageFiles.messageId, messageId))
+ .orderBy(asc(channelMessageFiles.sortOrder));
+ return rows.map((row) => row.fileId);
+};
+
+describe('channel message attachments', () => {
+ it('records attachments in the order sent and matches them on retry', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(channel.id, 'Coder');
+ const [first, second] = [await createFile('b.txt'), await createFile('a.txt')];
+ const input = {
+ content: 'Review these',
+ fileIds: [first, second],
+ mentions: [agent.id],
+ requestKey: 'req-1',
+ routing: 'jev' as const,
+ };
+
+ const message = await asMember.send(channel.id, input);
+
+ expect(await attachmentsOf(message.id)).toEqual([first, second]);
+ await expect(asMember.send(channel.id, input)).resolves.toMatchObject({ id: message.id });
+ await expect(
+ asMember.send(channel.id, { ...input, fileIds: [second, first] }),
+ ).rejects.toMatchObject({ code: 'CONFLICT' });
+ expect(await attachmentsOf(message.id)).toEqual([first, second]);
+ });
+
+ it('hands attachments to the claimed run, without files deleted since', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(channel.id, 'Coder');
+ const [kept, deleted] = [await createFile('kept.txt'), await createFile('deleted.txt')];
+ const message = await asMember.send(channel.id, {
+ content: 'Review these',
+ fileIds: [kept, deleted],
+ mentions: [agent.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ await db.delete(files).where(eq(files.id, deleted));
+ const [job] = await jobsOf(db, message.id);
+
+ await execution.claim(channel.id, job.id, lease);
+
+ expect(await execution.input(channel.id, job.id)).toEqual([
+ expect.objectContaining({ fileIds: [kept], id: message.id }),
+ ]);
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/canonical.test.ts b/packages/database/src/repositories/channel/__tests__/canonical.test.ts
new file mode 100644
index 00000000000..1f6a3d54442
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/canonical.test.ts
@@ -0,0 +1,227 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import {
+ agentOperations,
+ agents,
+ channelMembers,
+ channelMessages,
+ channelThreads,
+ messages,
+ topics,
+ users,
+ workspaces,
+} from '../../../schemas';
+import { ChannelExecutionRepository } from '..';
+import {
+ createChannelFixture,
+ deviceConfig,
+ jobById,
+ jobsOf,
+ lease,
+ nativeConfig,
+ operationById,
+} from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-canonical');
+const execution = new ChannelExecutionRepository(db);
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const setup = async (config = nativeConfig) => {
+ const team = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(team.channel.id, 'Agent', config);
+ let counter = 0;
+ const claim = async (owner = false, threadId?: string) => {
+ const message = await (owner ? team.asOwner : team.asMember).send(team.channel.id, {
+ content: `Request ${++counter}`,
+ mentions: [agent.id],
+ requestKey: `request-${counter}`,
+ routing: 'fallback',
+ threadId,
+ });
+ const [job] = await jobsOf(db, message.id);
+ return (await execution.claim(team.channel.id, job.id, lease))!;
+ };
+ const finish = async ({ job }: Awaited<ReturnType<typeof claim>>) => {
+ await execution.accepted(team.channel.id, job.id, {});
+ await execution.saveDraft(team.channel.id, job.id, 'Final answer');
+ await execution.releaseWriter(team.channel.id, job.id);
+ };
+ return { ...team, agent, claim, finish };
+};
+
+const operationOf = (id: string | null) => operationById(db, id);
+
+describe('canonical channel persistence', () => {
+ it('attributes operations to the member Agent reference', async () => {
+ const team = await setup();
+ const [source] = await db
+ .insert(agents)
+ .values({ userId: fixture.ownerId, workspaceId: fixture.workspaceId })
+ .returning();
+ await db
+ .update(channelMembers)
+ .set({ agentId: source.id })
+ .where(eq(channelMembers.id, team.agent.id));
+
+ const claim = await team.claim();
+
+ expect(await operationOf(claim.job.operationId)).toMatchObject({
+ agentId: source.id,
+ userId: fixture.memberId,
+ });
+ });
+
+ it.each([nativeConfig, deviceConfig()])(
+ 'creates an operation with the actual requester for $runtime',
+ async (config) => {
+ const team = await setup(config);
+ const claim = await team.claim();
+ expect(claim.topic).toMatchObject({
+ userId: fixture.memberId,
+ agentId: team.agent.agentId,
+ mode: 'default',
+ trigger: 'channel',
+ });
+ expect(await operationOf(claim.job.operationId)).toMatchObject({
+ userId: fixture.memberId,
+ workspaceId: fixture.workspaceId,
+ topicId: claim.topic.id,
+ model: config.model,
+ provider: config.provider,
+ trigger: 'channel',
+ });
+ expect(claim.job.operationId).toMatch(/^op_/);
+ },
+ );
+
+ it('reuses the topic and supplies only new public input after a completed run', async () => {
+ const team = await setup();
+ const first = await team.claim();
+ await db.insert(messages).values({
+ topicId: first.topic.id,
+ userId: fixture.memberId,
+ role: 'assistant',
+ content: 'PRIVATE transcript',
+ });
+ await team.finish(first);
+ expect((await operationOf(first.job.operationId)).status).toBe('done');
+ // Physical release may precede publication, and only the saved final answer is published.
+ await execution.publish(team.channel.id, first.job.id);
+
+ const second = await team.claim();
+ expect(second.topic.id).toBe(first.topic.id);
+ expect(
+ (await execution.input(team.channel.id, second.job.id)).map((message) => message.content),
+ ).toEqual(['Request 2']);
+
+ await execution.accepted(team.channel.id, first.job.id, {});
+ await execution.fail(team.channel.id, first.job.id, { message: 'Late failure' });
+ expect((await operationOf(first.job.operationId)).status).toBe('done');
+ expect((await jobById(db, first.job.id)).status).toBe('completed');
+ });
+
+ it.each(['other requester', 'deleted topic', 'branch'])(
+ 'starts the next run (%s) in a new topic and preserves old run identity',
+ async (reason) => {
+ const team = await setup();
+ const first = await team.claim();
+ await team.finish(first);
+ if (reason === 'deleted topic') await db.delete(topics).where(eq(topics.id, first.topic.id));
+ let threadId: string | undefined;
+ if (reason === 'branch') {
+ const [thread] = await db
+ .insert(channelThreads)
+ .values({
+ channelId: team.channel.id,
+ rootMessageId: first.job.messageId,
+ rootSequence: 1,
+ followerMemberIds: [team.agent.id],
+ })
+ .returning();
+ threadId = thread.id;
+ }
+
+ const second = await team.claim(reason === 'other requester', threadId);
+
+ expect(second.topic.id).not.toBe(first.topic.id);
+ expect(second.topic.userId).toBe(
+ reason === 'other requester' ? fixture.ownerId : fixture.memberId,
+ );
+ expect((await operationOf(first.job.operationId)).topicId).toBe(
+ reason === 'deleted topic' ? null : first.topic.id,
+ );
+ },
+ );
+
+ it('merges the hetero resume id into the run topic metadata', async () => {
+ const team = await setup(deviceConfig());
+ const claim = await team.claim();
+ await db
+ .update(topics)
+ .set({ metadata: { model: 'preserved-model' } })
+ .where(eq(topics.id, claim.topic.id));
+
+ await execution.accepted(team.channel.id, claim.job.id, { nativeSessionId: 'cli-resume' });
+
+ const [topic] = await db.select().from(topics).where(eq(topics.id, claim.topic.id));
+ expect(topic.metadata).toMatchObject({
+ model: 'preserved-model',
+ heteroSessionId: 'cli-resume',
+ });
+ });
+
+ it('does not create an operation for a blocked directory claim', async () => {
+ const first = await setup(deviceConfig());
+ await first.claim();
+ const second = await setup(deviceConfig());
+ expect(await second.claim()).toBeNull();
+ expect(
+ await db
+ .select()
+ .from(agentOperations)
+ .where(eq(agentOperations.agentId, second.agent.agentId!)),
+ ).toHaveLength(0);
+ expect(
+ await db.select().from(topics).where(eq(topics.agentId, second.agent.agentId!)),
+ ).toHaveLength(0);
+ });
+
+ it('preserves the public timeline when its creator account is deleted', async () => {
+ const team = await setup();
+ const claim = await team.claim(true);
+ await db
+ .update(workspaces)
+ .set({ primaryOwnerId: fixture.memberId })
+ .where(eq(workspaces.id, fixture.workspaceId));
+ await db.delete(users).where(eq(users.id, fixture.ownerId));
+ expect(
+ await db.select().from(channelMessages).where(eq(channelMessages.id, claim.job.messageId)),
+ ).toHaveLength(1);
+ });
+
+ it('does not resurrect an operation already completed by the runtime', async () => {
+ const team = await setup();
+ const claim = await team.claim();
+ await db
+ .update(agentOperations)
+ .set({ status: 'done', totalTokens: 42, traceS3Key: 'trace' })
+ .where(eq(agentOperations.id, claim.job.operationId!));
+ await execution.accepted(team.channel.id, claim.job.id, {});
+ await execution.fail(team.channel.id, claim.job.id, { message: 'late' });
+ expect(await jobById(db, claim.job.id)).toMatchObject({
+ acceptedAt: expect.any(Date),
+ publicationRevoked: false,
+ status: 'running',
+ });
+ expect(await operationOf(claim.job.operationId)).toMatchObject({
+ status: 'done',
+ totalTokens: 42,
+ traceS3Key: 'trace',
+ });
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/claimGuards.test.ts b/packages/database/src/repositories/channel/__tests__/claimGuards.test.ts
new file mode 100644
index 00000000000..b02c78908bc
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/claimGuards.test.ts
@@ -0,0 +1,154 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { UserModel } from '../../../models/user';
+import { channelJobs, channelMemberGrants, channelMembers, devices } from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { ChannelExecutionRepository, ChannelRepository } from '..';
+import { createChannelFixture, deviceConfig, jobsOf, lease } from './testUtils';
+
+const db: LobeChatDatabase = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-claim-guards');
+const execution = new ChannelExecutionRepository(db);
+
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const jobById = async (jobId: string) => {
+ const [job] = await db.select().from(channelJobs).where(eq(channelJobs.id, jobId));
+ return job;
+};
+
+/** Posts as `model`, mentioning `agentId`, and returns the queued job. */
+const request = async (
+ model: ChannelRepository,
+ channelId: string,
+ agentId: string,
+ key: string,
+) => {
+ const message = await model.send(channelId, {
+ content: key,
+ mentions: [agentId],
+ requestKey: key,
+ routing: 'jev',
+ });
+ const [job] = await jobsOf(db, message.id);
+ return { job, message };
+};
+
+/** Claims and finishes a job with a published reply. */
+const answer = async (channelId: string, jobId: string) => {
+ await execution.claim(channelId, jobId, lease);
+ await execution.accepted(channelId, jobId, { nativeSessionId: 's' });
+ await execution.saveDraft(channelId, jobId, 'Answer');
+ await execution.publish(channelId, jobId);
+ await execution.releaseWriter(channelId, jobId);
+};
+
+describe('claim guards', () => {
+ it('requires an approved grant that matches the device, directory and owner', async () => {
+ const { asOwner, channel, member } = await fixture.createTeamChannel();
+ // A private device owned by the member, not shared with the workspace.
+ await db
+ .insert(devices)
+ .values({ deviceId: 'device-2', identitySource: 'fallback', userId: fixture.memberId });
+ const agent = await fixture.addAgent(
+ channel.id,
+ 'Coder',
+ deviceConfig('/repo', 'device-2', fixture.memberId),
+ );
+ const grant = {
+ channelId: channel.id,
+ deviceId: 'device-2',
+ deviceOwnerId: fixture.memberId,
+ memberId: agent.id,
+ requestedByMemberId: member.id,
+ status: 'approved' as const,
+ workingDirectory: '/elsewhere',
+ };
+ const first = await request(asOwner, channel.id, agent.id, 'first');
+
+ // No grant at all fails closed.
+ expect(await execution.claim(channel.id, first.job.id, lease)).toBeNull();
+ expect(await jobById(first.job.id)).toMatchObject({ blockedCode: 'device_approval_pending' });
+
+ // An approval for another directory does not count.
+ const [mismatched] = await db.insert(channelMemberGrants).values(grant).returning();
+ expect(await execution.claim(channel.id, first.job.id, lease)).toBeNull();
+
+ await db
+ .update(channelMemberGrants)
+ .set({ workingDirectory: '/repo' })
+ .where(eq(channelMemberGrants.id, mismatched.id));
+ await answer(channel.id, first.job.id);
+
+ // The grant goes with the owner's account; the device stays locked to this channel.
+ await UserModel.deleteUser(db, fixture.memberId);
+ const second = await request(asOwner, channel.id, agent.id, 'second');
+ expect(await execution.claim(channel.id, second.job.id, lease)).toBeNull();
+ expect(await jobById(second.job.id)).toMatchObject({ blockedCode: 'device_approval_pending' });
+ });
+
+ it('runs a personal channel only on its owner device', async () => {
+ const model = new ChannelRepository(db, fixture.ownerId);
+ const { channel } = await model.create({ title: 'Personal' });
+ const foreign = await fixture.addAgent(
+ channel.id,
+ 'Foreign',
+ deviceConfig('/repo', 'device-3', fixture.memberId),
+ );
+ const own = await fixture.addAgent(
+ channel.id,
+ 'Own',
+ deviceConfig('/repo', 'device-3', fixture.ownerId),
+ );
+
+ const blocked = await request(model, channel.id, foreign.id, 'foreign');
+ expect(await execution.claim(channel.id, blocked.job.id, lease)).toBeNull();
+ expect(await jobById(blocked.job.id)).toMatchObject({ blockedCode: 'unavailable' });
+
+ const allowed = await request(model, channel.id, own.id, 'own');
+ expect(await execution.claim(channel.id, allowed.job.id, lease)).not.toBeNull();
+ });
+
+ it('cancels a job whose requester left the channel', async () => {
+ const { asMember, channel, member } = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(channel.id, 'Coder');
+ const { job } = await request(asMember, channel.id, agent.id, 'req');
+
+ await db.update(channelMembers).set({ active: false }).where(eq(channelMembers.id, member.id));
+
+ expect(await execution.claim(channel.id, job.id, lease)).toBeNull();
+ expect((await jobById(job.id)).status).toBe('cancelled');
+ });
+
+ it('gives a late-routed request the history up to itself', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(channel.id, 'Coder');
+ const unmentioned = await asMember.send(channel.id, {
+ content: 'Who can help?',
+ requestKey: 'unmentioned',
+ routing: 'jev',
+ });
+ const later = await request(asMember, channel.id, agent.id, 'later');
+ await answer(channel.id, later.job.id);
+
+ await execution.resolveRouting(channel.id, unmentioned.id, 1, {
+ memberIds: [agent.id],
+ reason: 'Coder can help',
+ status: 'assigned',
+ });
+ const [job] = await jobsOf(db, unmentioned.id);
+ const { job: claimed } = (await execution.claim(channel.id, job.id, lease))!;
+
+ expect(claimed.manifest).toMatchObject({
+ cutoffSequence: unmentioned.sequence,
+ requestMessageId: unmentioned.id,
+ });
+ expect(await execution.input(channel.id, job.id)).toEqual([
+ expect.objectContaining({ content: 'Who can help?', id: unmentioned.id }),
+ ]);
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/execution.test.ts b/packages/database/src/repositories/channel/__tests__/execution.test.ts
new file mode 100644
index 00000000000..6d5bb2c26ba
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/execution.test.ts
@@ -0,0 +1,512 @@
+// @vitest-environment node
+import { eq, sql } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import {
+ agentOperations,
+ channelJobs,
+ channelMessages,
+ channels,
+ channelThreads,
+ topics,
+} from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import type { ChannelSendInput } from '..';
+import { ChannelExecutionRepository } from '..';
+import { claimJob } from '../claim';
+import { lockChannel } from '../transaction';
+import {
+ createChannelFixture,
+ deviceConfig,
+ jobsOf,
+ lease,
+ nativeConfig,
+ operationById,
+} from './testUtils';
+
+const db: LobeChatDatabase = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-execution');
+const execution = new ChannelExecutionRepository(db);
+// Racing transactions need separate connections; PGlite runs them one after another.
+const isServerDB = process.env.TEST_SERVER_DB === '1';
+
+/** Resolves once some session in this database is waiting on a lock. */
+const waitForLockWaiter = async () => {
+ for (let attempt = 0; attempt < 100; attempt++) {
+ const { rows } = await db.execute<{ waiting: number }>(
+ sql`SELECT count(*)::int AS waiting FROM pg_stat_activity
+ WHERE datname = current_database() AND wait_event_type = 'Lock'`,
+ );
+ if (rows[0]?.waiting) return;
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ }
+ throw new Error('No transaction started waiting for a lock');
+};
+
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+/** A team channel with one Agent and a message mentioning it. */
+const mentionAgent = async (config = deviceConfig()) => {
+ const team = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(team.channel.id, 'Coder', config);
+ const message = await team.asMember.send(team.channel.id, {
+ content: 'Fix it',
+ mentions: [agent.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ const [job] = await jobsOf(db, message.id);
+
+ return { ...team, agent, job, message };
+};
+
+const jobById = async (jobId: string) => {
+ const [job] = await db.select().from(channelJobs).where(eq(channelJobs.id, jobId));
+ return job;
+};
+
+const operationOf = async (jobId: string) => operationById(db, (await jobById(jobId)).operationId);
+
+describe('ChannelExecutionRepository', () => {
+ it('claims, accepts, publishes and releases a job', async () => {
+ const { agent, channel, job, member, message } = await mentionAgent();
+
+ const claim = await execution.claim(channel.id, job.id, lease);
+ expect(claim?.job).toMatchObject({
+ deviceId: 'device-1',
+ leaseOwner: 'worker-1',
+ requesterMemberId: member.id,
+ status: 'running',
+ workingDirectory: '/repo',
+ writerHeld: true,
+ });
+ expect(claim?.job.manifest).toEqual({
+ afterSequence: 0,
+ cutoffSequence: 1,
+ requestMessageId: message.id,
+ requesterMemberId: member.id,
+ self: { agentId: agent.agentId, memberId: agent.id, name: 'Coder' },
+ threadId: null,
+ threadRootSequence: null,
+ });
+ expect(await execution.input(channel.id, job.id)).toEqual([
+ expect.objectContaining({ author: { id: fixture.memberId, name: 'mia', type: 'user' } }),
+ ]);
+
+ await execution.accepted(channel.id, job.id, {
+ nativeSessionId: 'session-1',
+ nativeTurnId: 'turn-1',
+ });
+ expect((await jobById(job.id)).acceptedAt).toBeInstanceOf(Date);
+ const [topic] = await db.select().from(topics).where(eq(topics.id, claim!.topic.id));
+ expect(topic.metadata?.heteroSessionId).toBe('session-1');
+ expect(await operationOf(job.id)).toMatchObject({
+ metadata: { nativeTurnId: 'turn-1' },
+ status: 'running',
+ topicId: claim!.topic.id,
+ });
+
+ await execution.saveDraft(channel.id, job.id, 'Fixed');
+ await expect(execution.saveDraft(channel.id, job.id, 'Changed')).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+
+ const replyId = await execution.publish(channel.id, job.id);
+ expect(await execution.publish(channel.id, job.id)).toBe(replyId);
+ const [reply] = await db.select().from(channelMessages).where(eq(channelMessages.id, replyId));
+ expect(reply).toMatchObject({
+ agentId: agent.agentId,
+ userId: null,
+ replyToId: message.id,
+ routingStatus: 'reply',
+ sequence: 2,
+ });
+ expect(reply.content).toBe('Fixed');
+ expect((await operationOf(job.id)).status).toBe('running');
+ expect((await jobById(job.id)).status).toBe('completed');
+
+ const releasedState = {
+ leaseOwner: null,
+ publishedMessageId: replyId,
+ status: 'completed',
+ writerHeld: false,
+ };
+ await execution.releaseWriter(channel.id, job.id);
+ expect(await jobById(job.id)).toMatchObject(releasedState);
+ expect((await operationOf(job.id)).status).toBe('done');
+ await execution.releaseWriter(channel.id, job.id);
+ expect(await jobById(job.id)).toMatchObject(releasedState);
+ });
+
+ it('continues the Agent topic and its hetero session with only new public input', async () => {
+ const { agent, asMember, channel, job } = await mentionAgent();
+ const first = (await execution.claim(channel.id, job.id, lease))!;
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 'session-1' });
+ await execution.saveDraft(channel.id, job.id, 'Done');
+ await execution.publish(channel.id, job.id);
+ await execution.releaseWriter(channel.id, job.id);
+
+ const next = await asMember.send(channel.id, {
+ content: 'Again',
+ mentions: [agent.id],
+ requestKey: 'req-2',
+ routing: 'jev',
+ });
+ const [nextJob] = await jobsOf(db, next.id);
+ const second = (await execution.claim(channel.id, nextJob.id, lease))!;
+
+ expect(second.topic.id).toBe(first.topic.id);
+ expect(second.topic.metadata?.heteroSessionId).toBe('session-1');
+ expect((await execution.input(channel.id, nextJob.id)).map((m) => m.sequence)).toEqual([3]);
+ expect((await operationById(db, second.job.operationId)).topicId).toBe(second.topic.id);
+ });
+
+ it('freezes a branch cutoff instead of message content and reads it after later sends', async () => {
+ const { asMember, channel, member } = await fixture.createTeamChannel();
+ const mainAgent = await fixture.addAgent(channel.id, 'Main', nativeConfig);
+ const threadAgent = await fixture.addAgent(channel.id, 'Thread', nativeConfig);
+ const send = (requestKey: string, input: Partial<ChannelSendInput> = {}) =>
+ asMember.send(channel.id, { content: requestKey, requestKey, routing: 'jev', ...input });
+ const root = await send('root');
+ const [thread] = await db
+ .insert(channelThreads)
+ .values({ channelId: channel.id, rootMessageId: root.id, rootSequence: root.sequence })
+ .returning();
+ await send('main-after-root');
+ const mainRequest = await send('main-request', { mentions: [mainAgent.id] });
+ const threadRequest = await send('thread-request', {
+ mentions: [threadAgent.id],
+ threadId: thread.id,
+ });
+ const [mainJob] = await jobsOf(db, mainRequest.id);
+ const [threadJob] = await jobsOf(db, threadRequest.id);
+ await expect(execution.input(channel.id, mainJob.id)).rejects.toMatchObject({
+ code: 'NOT_FOUND',
+ });
+
+ const mainClaim = (await execution.claim(channel.id, mainJob.id, lease))!;
+ const threadClaim = (await execution.claim(channel.id, threadJob.id, lease))!;
+ await send('main-after-claim');
+ await send('thread-after-claim', { threadId: thread.id });
+
+ // The job stores where its input ends, so its size does not grow with the branch.
+ expect(mainClaim.job.manifest).toEqual({
+ afterSequence: 0,
+ cutoffSequence: mainRequest.sequence,
+ requestMessageId: mainRequest.id,
+ requesterMemberId: member.id,
+ self: { agentId: mainAgent.agentId, memberId: mainAgent.id, name: 'Main' },
+ threadId: null,
+ threadRootSequence: null,
+ });
+ expect(threadClaim.job.manifest).toMatchObject({
+ cutoffSequence: threadRequest.sequence,
+ threadId: thread.id,
+ threadRootSequence: root.sequence,
+ });
+ const contents = async (jobId: string) =>
+ (await execution.input(channel.id, jobId)).map((message) => message.content);
+ expect(await contents(mainJob.id)).toEqual(['root', 'main-after-root', 'main-request']);
+ expect(await contents(threadJob.id)).toEqual(['root', 'thread-request']);
+ });
+
+ it('answers in message order and holds one writer per member', async () => {
+ const { agent, asMember, channel, job } = await mentionAgent();
+ const next = await asMember.send(channel.id, {
+ content: 'Second',
+ mentions: [agent.id],
+ requestKey: 'req-2',
+ routing: 'jev',
+ });
+ const [nextJob] = await jobsOf(db, next.id);
+
+ expect(await execution.claim(channel.id, nextJob.id, lease)).toBeNull();
+ expect(await execution.claim(channel.id, job.id, lease)).not.toBeNull();
+ expect(await execution.claim(channel.id, nextJob.id, lease)).toBeNull();
+
+ await execution.fail(channel.id, job.id, { message: 'boom', notSubmitted: true });
+ expect(await jobById(job.id)).toMatchObject({ status: 'failed', writerHeld: false });
+ expect(await execution.claim(channel.id, nextJob.id, lease)).not.toBeNull();
+ });
+
+ it('blocks a job while another channel uses the same device directory', async () => {
+ const first = await mentionAgent();
+ await execution.claim(first.channel.id, first.job.id, lease);
+
+ const asOther = await fixture.createTeamChannel('Other');
+ const otherAgent = await fixture.addAgent(asOther.channel.id, 'Coder', deviceConfig());
+ const message = await asOther.asMember.send(asOther.channel.id, {
+ content: 'Same repo',
+ mentions: [otherAgent.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ const [job] = await jobsOf(db, message.id);
+
+ expect(await execution.claim(asOther.channel.id, job.id, lease)).toBeNull();
+ expect(await jobById(job.id)).toMatchObject({ blockedCode: 'directory_locked' });
+
+ // Isolation lets the member move on but does not free the directory.
+ await execution.isolate(first.channel.id, first.job.id, 'termination unconfirmed');
+ expect(await jobById(first.job.id)).toMatchObject({
+ isolatedAt: expect.any(Date),
+ status: 'failed',
+ writerHeld: true,
+ });
+ expect(await execution.claim(asOther.channel.id, job.id, lease)).toBeNull();
+
+ await execution.releaseWriter(first.channel.id, first.job.id);
+ expect(await jobById(first.job.id)).toMatchObject({ status: 'failed', writerHeld: false });
+ expect(await execution.claim(asOther.channel.id, job.id, lease)).not.toBeNull();
+ expect(await jobById(job.id)).toMatchObject({ blockedCode: null, status: 'running' });
+ });
+
+ it.skipIf(!isServerDB)(
+ 'blocks the loser of a concurrent claim on the same directory',
+ async () => {
+ const first = await mentionAgent();
+ const other = await fixture.createTeamChannel('Other');
+ const otherAgent = await fixture.addAgent(other.channel.id, 'Coder', deviceConfig());
+ const message = await other.asMember.send(other.channel.id, {
+ content: 'Same repo',
+ mentions: [otherAgent.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ const [job] = await jobsOf(db, message.id);
+
+ // The first claim takes the writer but has not committed when the second one checks.
+ let inserted!: () => void;
+ const writerTaken = new Promise<void>((resolve) => (inserted = resolve));
+ let release!: () => void;
+ const released = new Promise<void>((resolve) => (release = resolve));
+ const winner = db.transaction(async (tx) => {
+ const channel = await lockChannel(tx, first.channel.id);
+ await claimJob(tx, channel, first.job.id, lease);
+ inserted();
+ await released;
+ });
+
+ await writerTaken;
+ const loser = execution.claim(other.channel.id, job.id, lease);
+ await waitForLockWaiter();
+ release();
+ await winner;
+
+ expect(await loser).toBeNull();
+ expect(
+ await db
+ .select()
+ .from(agentOperations)
+ .where(eq(agentOperations.agentId, otherAgent.agentId!)),
+ ).toHaveLength(0);
+ expect(
+ await db.select().from(topics).where(eq(topics.agentId, otherAgent.agentId!)),
+ ).toHaveLength(0);
+ expect(await jobById(job.id)).toMatchObject({
+ blockedCode: 'directory_locked',
+ operationId: null,
+ status: 'queued',
+ writerHeld: false,
+ });
+ },
+ );
+
+ it('fails the job when the writer ends without a reply', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 's' });
+
+ await execution.releaseWriter(channel.id, job.id);
+
+ expect(await jobById(job.id)).toMatchObject({
+ publicationRevoked: true,
+ status: 'failed',
+ writerHeld: false,
+ });
+ expect(await operationOf(job.id)).toMatchObject({
+ error: { message: 'The run ended without a reply' },
+ status: 'error',
+ });
+ });
+
+ it('settles the job of an unknown execution without redelivering it', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.executionUnknown(channel.id, job.id, 'receipt lost');
+ expect((await operationOf(job.id)).status).toBe('abandoned');
+
+ expect(await jobById(job.id)).toMatchObject({
+ publicationRevoked: true,
+ status: 'failed',
+ writerHeld: true,
+ });
+
+ // A late receipt cannot revive it.
+ await expect(
+ execution.accepted(channel.id, job.id, { nativeSessionId: 's' }),
+ ).rejects.toMatchObject({ code: 'CONFLICT' });
+ expect((await jobById(job.id)).acceptedAt).toBeNull();
+
+ await execution.releaseWriter(channel.id, job.id);
+
+ expect(await jobById(job.id)).toMatchObject({
+ publicationRevoked: true,
+ status: 'failed',
+ writerHeld: false,
+ });
+ });
+
+ it('keeps an unknown execution unpublishable after the runtime settled its operation', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ const { operationId } = await jobById(job.id);
+ await db
+ .update(agentOperations)
+ .set({ status: 'error' })
+ .where(eq(agentOperations.id, operationId!));
+
+ await execution.executionUnknown(channel.id, job.id, 'receipt lost');
+
+ await expect(
+ execution.accepted(channel.id, job.id, { nativeSessionId: 's' }),
+ ).rejects.toMatchObject({ code: 'CONFLICT' });
+ await expect(execution.publish(channel.id, job.id)).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+ });
+
+ it('fails an accepted draft whose execution became unknown', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 's' });
+ await execution.saveDraft(channel.id, job.id, 'Done');
+ const { operationId } = await jobById(job.id);
+ await db
+ .update(agentOperations)
+ .set({ status: 'done' })
+ .where(eq(agentOperations.id, operationId!));
+
+ await execution.executionUnknown(channel.id, job.id, 'receipt lost');
+ await execution.releaseWriter(channel.id, job.id);
+
+ expect(await jobById(job.id)).toMatchObject({
+ publicationRevoked: true,
+ status: 'failed',
+ writerHeld: false,
+ });
+ await expect(execution.publish(channel.id, job.id)).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+ });
+
+ it('still releases the writer after its operation row is gone', async () => {
+ const { agent, asMember, channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ const { operationId } = await jobById(job.id);
+ await db.delete(agentOperations).where(eq(agentOperations.id, operationId!));
+
+ await execution.releaseWriter(channel.id, job.id);
+
+ expect(await jobById(job.id)).toMatchObject({
+ operationId: null,
+ status: 'failed',
+ writerHeld: false,
+ });
+ const next = await asMember.send(channel.id, {
+ content: 'Next',
+ mentions: [agent.id],
+ requestKey: 'req-2',
+ routing: 'jev',
+ });
+ const [nextJob] = await jobsOf(db, next.id);
+ expect(await execution.claim(channel.id, nextJob.id, lease)).not.toBeNull();
+ });
+
+ it('ignores a late failure once the job published or settled', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 's' });
+ await execution.saveDraft(channel.id, job.id, 'Done');
+ const replyId = await execution.publish(channel.id, job.id);
+
+ await execution.fail(channel.id, job.id, { message: 'late error' });
+ expect(await jobById(job.id)).toMatchObject({
+ publicationRevoked: false,
+ publishedMessageId: replyId,
+ status: 'completed',
+ writerHeld: true,
+ });
+ expect(await operationOf(job.id)).toMatchObject({ error: null, status: 'running' });
+
+ await execution.releaseWriter(channel.id, job.id);
+ await execution.fail(channel.id, job.id, { message: 'later error' });
+ expect((await jobById(job.id)).status).toBe('completed');
+ expect(await operationOf(job.id)).toMatchObject({ error: null, status: 'done' });
+ });
+
+ it('keeps the first outcome of a released job', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.executionUnknown(channel.id, job.id, 'receipt lost');
+ await execution.releaseWriter(channel.id, job.id);
+
+ await execution.fail(channel.id, job.id, { message: 'late error' });
+
+ expect(await operationOf(job.id)).toMatchObject({
+ error: { message: 'receipt lost' },
+ status: 'abandoned',
+ });
+ expect((await jobById(job.id)).status).toBe('failed');
+ });
+
+ it('keeps an accepted draft publishable after the writer is released', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 's' });
+ await execution.saveDraft(channel.id, job.id, 'Done');
+
+ await execution.releaseWriter(channel.id, job.id);
+ expect(await jobById(job.id)).toMatchObject({ status: 'running', writerHeld: false });
+
+ await execution.publish(channel.id, job.id);
+ expect((await jobById(job.id)).status).toBe('completed');
+ });
+
+ it('refuses unclaimed or revoked jobs and archived channels', async () => {
+ const { channel, job } = await mentionAgent();
+ await expect(
+ execution.accepted(channel.id, job.id, { nativeSessionId: 's' }),
+ ).rejects.toMatchObject({ code: 'NOT_FOUND' });
+
+ await execution.claim(channel.id, job.id, lease);
+ await expect(execution.publish(channel.id, job.id)).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+
+ await execution.fail(channel.id, job.id, { message: 'boom', notSubmitted: true });
+ await expect(
+ execution.accepted(channel.id, job.id, { nativeSessionId: 's' }),
+ ).rejects.toMatchObject({ code: 'CONFLICT' });
+
+ await db.update(channels).set({ archived: true }).where(eq(channels.id, channel.id));
+ const [rerun] = await db
+ .insert(channelJobs)
+ .values({ ...job, deliveryKey: 'retry', id: undefined, status: 'queued' })
+ .returning();
+ expect(await execution.claim(channel.id, rerun.id, lease)).toBeNull();
+ });
+
+ it('renews the lease only for the live owner', async () => {
+ const { channel, job } = await mentionAgent();
+ await execution.claim(channel.id, job.id, lease);
+
+ expect(await execution.heartbeat(job.id, lease)).toBe(true);
+ expect(await execution.heartbeat(job.id, { ...lease, leaseOwner: 'other' })).toBe(false);
+
+ await execution.fail(channel.id, job.id, { message: 'boom', notSubmitted: true });
+ expect(await execution.heartbeat(job.id, lease)).toBe(false);
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/identity.test.ts b/packages/database/src/repositories/channel/__tests__/identity.test.ts
new file mode 100644
index 00000000000..a20edf76ec6
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/identity.test.ts
@@ -0,0 +1,289 @@
+// @vitest-environment node
+import { CHANNEL_DELETED_AGENT_NAME, CHANNEL_DELETED_USER_NAME } from '@lobechat/types';
+import { and, eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { agents, channelMembers, channelMessages, channels, users } from '../../../schemas';
+import { ChannelExecutionRepository, ChannelRepository } from '..';
+import { createChannelFixture, jobsOf, lease } from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-identity');
+const execution = new ChannelExecutionRepository(db);
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const sendInput = { content: 'Hello', requestKey: 'hello', routing: 'jev' as const };
+const createAgent = async (workspaceId: string | null = fixture.workspaceId) => {
+ const [agent] = await db
+ .insert(agents)
+ .values({
+ name: 'Assistant',
+ userId: fixture.ownerId,
+ workspaceId,
+ })
+ .returning();
+ return agent;
+};
+
+const publish = async (channelId: string, messageId: string) => {
+ const [job] = await jobsOf(db, messageId);
+ const claim = (await execution.claim(channelId, job.id, lease))!;
+ expect(claim).not.toBeNull();
+ await execution.accepted(channelId, job.id, {});
+ await execution.saveDraft(channelId, job.id, 'Answer');
+ const replyId = await execution.publish(channelId, job.id);
+ await execution.releaseWriter(channelId, job.id);
+ return { claim, replyId };
+};
+
+describe('direct Channel identity', () => {
+ it.each([null, fixture.workspaceId])(
+ 'creates a private user/Agent conversation in scope %s',
+ async (workspaceId) => {
+ const agent = await createAgent(workspaceId);
+ const repository = new ChannelRepository(db, fixture.ownerId, workspaceId);
+ const { channel } = await repository.create({ agentId: agent.id, title: 'Direct' });
+ expect(channel).toMatchObject({
+ agentId: agent.id,
+ userId: fixture.ownerId,
+ visibility: 'private',
+ workspaceId,
+ });
+ const members = await db
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.channelId, channel.id));
+ expect(members).toHaveLength(2);
+ expect(members).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({ actorType: 'user', userId: fixture.ownerId }),
+ expect.objectContaining({ actorType: 'agent', agentId: agent.id }),
+ ]),
+ );
+ const request = await repository.send(channel.id, sendInput);
+ expect(request).toMatchObject({
+ userId: fixture.ownerId,
+ agentId: null,
+ routingStatus: 'directed',
+ });
+ const { replyId } = await publish(channel.id, request.id);
+ const [reply] = await db
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, replyId));
+ expect(reply).toMatchObject({ agentId: agent.id, userId: null });
+ },
+ );
+
+ it('reuses one direct conversation per person, Agent and scope', async () => {
+ const agent = await createAgent();
+ const repository = new ChannelRepository(db, fixture.ownerId, fixture.workspaceId);
+ const [first, second] = await Promise.all([
+ repository.create({ agentId: agent.id, title: 'Direct' }),
+ repository.create({ agentId: agent.id, title: 'Again' }),
+ ]);
+ expect(second.channel.id).toBe(first.channel.id);
+ expect(second.member.id).toBe(first.member.id);
+ expect(await db.select().from(channels).where(eq(channels.agentId, agent.id))).toHaveLength(1);
+ await expect(
+ db.insert(channels).values({
+ agentId: agent.id,
+ title: 'Duplicate',
+ userId: fixture.ownerId,
+ workspaceId: fixture.workspaceId,
+ }),
+ ).rejects.toThrow();
+
+ const other = await new ChannelRepository(db, fixture.memberId, fixture.workspaceId).create({
+ agentId: agent.id,
+ title: 'Direct',
+ });
+ expect(other.channel.id).not.toBe(first.channel.id);
+
+ // A transferred Agent starts a new conversation in its new scope.
+ await db.update(agents).set({ workspaceId: null }).where(eq(agents.id, agent.id));
+ const personal = await new ChannelRepository(db, fixture.ownerId).create({
+ agentId: agent.id,
+ title: 'Direct',
+ });
+ expect(personal.channel.id).not.toBe(first.channel.id);
+ expect(personal.channel.workspaceId).toBeNull();
+ });
+
+ it('keeps a group unbound even when it contains a single Agent', async () => {
+ const team = await fixture.createTeamChannel();
+ await fixture.addAgent(team.channel.id, 'Only Agent');
+ expect(team.channel.agentId).toBeNull();
+ expect((await team.asMember.send(team.channel.id, sendInput)).routingStatus).toBe('pending');
+ });
+
+ it.each(['public', 'empty', 'missing', 'private Agent', 'foreign scope'])(
+ 'rejects %s direct creation without leaving a Channel behind',
+ async (reason) => {
+ const agent = await createAgent(reason === 'foreign scope' ? null : fixture.workspaceId);
+ if (reason === 'private Agent')
+ await db
+ .update(agents)
+ .set({ userId: fixture.memberId, visibility: 'private' })
+ .where(eq(agents.id, agent.id));
+ const repository = new ChannelRepository(db, fixture.ownerId, fixture.workspaceId);
+ await expect(
+ repository.create({
+ agentId: reason === 'empty' ? '' : reason === 'missing' ? 'missing' : agent.id,
+ title: 'Invalid',
+ visibility: reason === 'public' ? 'public' : 'private',
+ }),
+ ).rejects.toMatchObject({
+ code: ['public', 'empty'].includes(reason) ? 'BAD_REQUEST' : 'NOT_FOUND',
+ });
+ expect(await repository.list()).toEqual([]);
+ },
+ );
+
+ it('rejects additional Agents and keeps other workspace users outside the direct conversation', async () => {
+ const agent = await createAgent();
+ const other = await createAgent();
+ const repository = new ChannelRepository(db, fixture.ownerId, fixture.workspaceId);
+ const { channel } = await repository.create({ agentId: agent.id, title: 'Direct' });
+ await expect(repository.addAgent(channel.id, { agentId: other.id })).rejects.toMatchObject({
+ code: 'BAD_REQUEST',
+ });
+ await expect(repository.addAgent(channel.id, { agentId: agent.id })).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+ // Even an accidentally granted membership must not expose a direct conversation.
+ await fixture.addPerson(channel.id, fixture.memberId, 'admin');
+ const outsider = new ChannelRepository(db, fixture.memberId, fixture.workspaceId);
+ expect(await outsider.findAccess(channel.id)).toBeUndefined();
+ expect(await outsider.list()).toEqual([]);
+ await expect(outsider.send(channel.id, sendInput)).rejects.toMatchObject({ code: 'NOT_FOUND' });
+ await expect(
+ db.update(channels).set({ visibility: 'public' }).where(eq(channels.id, channel.id)),
+ ).rejects.toThrow();
+ });
+
+ it('deletes direct conversations with their Agent while retaining group messages', async () => {
+ const agent = await createAgent();
+ const group = await fixture.createTeamChannel();
+ const member = await group.asOwner.addAgent(group.channel.id, { agentId: agent.id });
+ const { channel: direct } = await group.asOwner.create({ agentId: agent.id, title: 'Direct' });
+ const directRequest = await group.asOwner.send(direct.id, sendInput);
+ await publish(direct.id, directRequest.id);
+ const groupRequest = await group.asMember.send(group.channel.id, {
+ ...sendInput,
+ mentions: [member.id],
+ });
+ const { replyId } = await publish(group.channel.id, groupRequest.id);
+
+ await db.delete(agents).where(eq(agents.id, agent.id));
+ expect(await db.select().from(channels).where(eq(channels.id, direct.id))).toEqual([]);
+ expect(
+ await db.select().from(channelMessages).where(eq(channelMessages.channelId, direct.id)),
+ ).toEqual([]);
+ const [reply] = await db.select().from(channelMessages).where(eq(channelMessages.id, replyId));
+ expect(reply).toMatchObject({ agentId: null, userId: null, content: 'Answer' });
+ expect(await group.asMember.findAccess(group.channel.id)).toBeDefined();
+
+ const nextAgent = await fixture.addAgent(group.channel.id, 'Next');
+ const next = await group.asMember.send(group.channel.id, {
+ ...sendInput,
+ requestKey: 'next',
+ mentions: [nextAgent.id],
+ });
+ const [nextJob] = await jobsOf(db, next.id);
+ await execution.claim(group.channel.id, nextJob.id, lease);
+ expect(await execution.input(group.channel.id, nextJob.id)).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ id: replyId,
+ author: { id: null, name: CHANNEL_DELETED_AGENT_NAME, type: 'agent' },
+ }),
+ ]),
+ );
+ });
+});
+
+describe('direct message sender references', () => {
+ it('derives the sender from the authenticated member, ignoring supplied identities', async () => {
+ const team = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(team.channel.id, 'Agent');
+ const forged = { ...sendInput, userId: fixture.ownerId, agentId: agent.agentId };
+ expect(await team.asMember.send(team.channel.id, forged)).toMatchObject({
+ userId: fixture.memberId,
+ agentId: null,
+ });
+ });
+
+ it('publishes as the claimed Agent even if the member is later rebound', async () => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Original');
+ const request = await team.asMember.send(team.channel.id, {
+ ...sendInput,
+ mentions: [member.id],
+ });
+ const [job] = await jobsOf(db, request.id);
+ await execution.claim(team.channel.id, job.id, lease);
+ const replacement = await createAgent();
+ await db
+ .update(channelMembers)
+ .set({ agentId: replacement.id })
+ .where(eq(channelMembers.id, member.id));
+ await execution.accepted(team.channel.id, job.id, {});
+ await execution.saveDraft(team.channel.id, job.id, 'Original answer');
+ const replyId = await execution.publish(team.channel.id, job.id);
+ const [reply] = await db.select().from(channelMessages).where(eq(channelMessages.id, replyId));
+ expect(reply).toMatchObject({ agentId: member.agentId, userId: null });
+ await execution.releaseWriter(team.channel.id, job.id);
+ });
+
+ it('retains human message content with a deleted-user identity', async () => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Agent');
+ const request = await team.asMember.send(team.channel.id, {
+ ...sendInput,
+ mentions: [member.id],
+ });
+ const [job] = await jobsOf(db, request.id);
+ await execution.claim(team.channel.id, job.id, lease);
+ await db.delete(users).where(eq(users.id, fixture.memberId));
+ expect(await execution.input(team.channel.id, job.id)).toEqual([
+ expect.objectContaining({
+ content: 'Hello',
+ author: { id: null, name: CHANNEL_DELETED_USER_NAME, type: 'user' },
+ }),
+ ]);
+ });
+
+ it.each(['left', 'deleted'])(
+ 'does not route delayed requests after their author %s',
+ async (reason) => {
+ const team = await fixture.createTeamChannel();
+ const member = await fixture.addAgent(team.channel.id, 'Agent');
+ const request = await team.asMember.send(team.channel.id, sendInput);
+ if (reason === 'deleted') await db.delete(users).where(eq(users.id, fixture.memberId));
+ else
+ await db
+ .update(channelMembers)
+ .set({ active: false })
+ .where(
+ and(
+ eq(channelMembers.channelId, team.channel.id),
+ eq(channelMembers.userId, fixture.memberId),
+ ),
+ );
+ await execution.resolveRouting(team.channel.id, request.id, 1, {
+ memberIds: [member.id],
+ reason: 'Chosen',
+ status: 'assigned',
+ });
+ expect(await jobsOf(db, request.id)).toEqual([]);
+ const [unassigned] = await db
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, request.id));
+ expect(unassigned.routingStatus).toBe('unassigned');
+ },
+ );
+});
diff --git a/packages/database/src/repositories/channel/__tests__/routingStop.test.ts b/packages/database/src/repositories/channel/__tests__/routingStop.test.ts
new file mode 100644
index 00000000000..2acaffdf9ce
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/routingStop.test.ts
@@ -0,0 +1,191 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { channelMessages, channelThreads } from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { ChannelExecutionRepository } from '..';
+import { createChannelFixture, jobById, jobsOf, lease, operationById } from './testUtils';
+
+const db: LobeChatDatabase = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-routing-stop');
+const execution = new ChannelExecutionRepository(db);
+
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const messageById = async (messageId: string) => {
+ const [message] = await db
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, messageId));
+ return message;
+};
+
+describe('routing write-back', () => {
+ it('delivers a current Jev decision to the chosen candidates only', async () => {
+ const { asMember, channel, member } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ await fixture.addAgent(channel.id, 'Reviewer');
+ const message = await asMember.send(channel.id, {
+ content: 'Who knows?',
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+
+ expect(
+ await execution.resolveRouting(channel.id, message.id, 1, {
+ memberIds: [coder.id, 'chn_member_outsider'],
+ reason: 'Coder owns this code',
+ status: 'assigned',
+ }),
+ ).toBe(true);
+
+ expect(await messageById(message.id)).toMatchObject({
+ recipientMemberIds: [coder.id],
+ routingSource: 'jev',
+ routingStatus: 'assigned',
+ });
+ expect(await jobsOf(db, message.id)).toEqual([
+ expect.objectContaining({ memberId: coder.id, requesterMemberId: member.id }),
+ ]);
+ });
+
+ it('ignores a stale attempt after a retry', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const message = await asMember.send(channel.id, {
+ content: 'Who knows?',
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ await execution.resolveRouting(channel.id, message.id, 1, {
+ reason: 'Unclear',
+ status: 'unassigned',
+ });
+
+ const retried = await asMember.retryRouting(channel.id, message.id);
+ expect(retried).toMatchObject({ routingAttempt: 2, routingStatus: 'pending' });
+
+ const late = await execution.resolveRouting(channel.id, message.id, 1, {
+ memberIds: [coder.id],
+ reason: 'Late',
+ status: 'assigned',
+ });
+ expect(late).toBe(false);
+ expect(await jobsOf(db, message.id)).toEqual([]);
+ });
+
+ it('lets only the author or an admin retry routing', async () => {
+ const { asMember, asOwner, channel } = await fixture.createTeamChannel();
+ await fixture.addAgent(channel.id, 'Coder');
+ const message = await asOwner.send(channel.id, {
+ content: 'Who knows?',
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ await execution.resolveRouting(channel.id, message.id, 1, {
+ reason: 'Unclear',
+ status: 'unassigned',
+ });
+
+ await expect(asMember.retryRouting(channel.id, message.id)).rejects.toMatchObject({
+ code: 'FORBIDDEN',
+ });
+ await expect(asOwner.retryRouting(channel.id, message.id)).resolves.toMatchObject({
+ routingStatus: 'pending',
+ });
+ });
+});
+
+describe('stop', () => {
+ it('revokes a job so it can never publish, and lets its requester stop it', async () => {
+ const { asMember, asOwner, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const message = await asOwner.send(channel.id, {
+ content: 'Do it',
+ mentions: [coder.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ const [job] = await jobsOf(db, message.id);
+ await execution.claim(channel.id, job.id, lease);
+ await execution.accepted(channel.id, job.id, { nativeSessionId: 's' });
+ await execution.saveDraft(channel.id, job.id, 'Draft');
+
+ await expect(asMember.stop(channel.id, { jobId: job.id })).rejects.toMatchObject({
+ code: 'FORBIDDEN',
+ });
+ const pending = await asOwner.stop(channel.id, { jobId: job.id });
+
+ expect(pending.map((item) => item.id)).toEqual([job.id]);
+ expect(await jobById(db, job.id)).toMatchObject({
+ publicationRevoked: true,
+ status: 'cancelled',
+ writerHeld: true,
+ });
+ await expect(execution.publish(channel.id, job.id)).rejects.toMatchObject({
+ code: 'CONFLICT',
+ });
+
+ await execution.releaseWriter(channel.id, job.id);
+ expect(await jobById(db, job.id)).toMatchObject({ status: 'cancelled', writerHeld: false });
+ expect((await operationById(db, (await jobById(db, job.id)).operationId)).status).toBe(
+ 'interrupted',
+ );
+ });
+
+ it('stops a branch: closes pending routing and cancels queued jobs there only', async () => {
+ const { asMember, asOwner, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const root = await asOwner.send(channel.id, {
+ content: 'Root',
+ mentions: [coder.id],
+ requestKey: 'root',
+ routing: 'jev',
+ });
+ const [thread] = await db
+ .insert(channelThreads)
+ .values({
+ channelId: channel.id,
+ followerMemberIds: [coder.id],
+ rootMessageId: root.id,
+ rootSequence: root.sequence,
+ })
+ .returning();
+ const inThread = await asOwner.send(channel.id, {
+ content: 'In thread',
+ mentions: [coder.id],
+ requestKey: 'thread',
+ routing: 'jev',
+ threadId: thread.id,
+ });
+ const pending = await asOwner.send(channel.id, {
+ content: 'Anyone?',
+ requestKey: 'pending',
+ routing: 'jev',
+ });
+
+ await expect(asMember.stop(channel.id, { threadId: null })).rejects.toMatchObject({
+ code: 'FORBIDDEN',
+ });
+ await asOwner.stop(channel.id, { threadId: null });
+
+ expect(await messageById(pending.id)).toMatchObject({
+ routingAttempt: 2,
+ routingStatus: 'unassigned',
+ });
+ expect(
+ await execution.resolveRouting(channel.id, pending.id, 1, {
+ memberIds: [coder.id],
+ reason: 'Late',
+ status: 'assigned',
+ }),
+ ).toBe(false);
+ const [mainJob] = await jobsOf(db, root.id);
+ const [threadJob] = await jobsOf(db, inThread.id);
+ expect(mainJob.status).toBe('cancelled');
+ expect(threadJob.status).toBe('queued');
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/send.test.ts b/packages/database/src/repositories/channel/__tests__/send.test.ts
new file mode 100644
index 00000000000..956b6b3f92f
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/send.test.ts
@@ -0,0 +1,202 @@
+// @vitest-environment node
+import { CHANNEL_LIMITS } from '@lobechat/types';
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { channelMessages, channelThreads, messages, topics } from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { createChannelFixture, jobsOf } from './testUtils';
+
+const db: LobeChatDatabase = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-send');
+
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+describe('ChannelRepository.send', () => {
+ it('stores public content independently of ordinary messages and topics', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const input = { content: 'Public', requestKey: 'public', routing: 'fallback' as const };
+ const first = await asMember.send(channel.id, input);
+ expect(await asMember.send(channel.id, input)).toEqual(first);
+ expect(await db.select().from(channelMessages).where(eq(channelMessages.id, first.id))).toEqual(
+ [first],
+ );
+ expect(await db.select().from(messages).where(eq(messages.id, first.id))).toEqual([]);
+ expect(
+ await db.select().from(topics).where(eq(topics.workspaceId, fixture.workspaceId)),
+ ).toEqual([]);
+ });
+
+ it('queues a job per mentioned Agent, on behalf of the sender', async () => {
+ const { asMember, channel, member } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ await fixture.addAgent(channel.id, 'Reviewer');
+
+ const message = await asMember.send(channel.id, {
+ content: 'Fix the bug',
+ mentions: [coder.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+
+ expect(message).toMatchObject({
+ agentId: null,
+ userId: fixture.memberId,
+ recipientMemberIds: [coder.id],
+ routingSource: 'explicit',
+ routingStatus: 'directed',
+ sequence: 1,
+ });
+ const jobs = await jobsOf(db, message.id);
+ expect(jobs).toEqual([
+ expect.objectContaining({
+ memberId: coder.id,
+ requesterMemberId: member.id,
+ status: 'queued',
+ }),
+ ]);
+ });
+
+ it('wakes no Agent when only people are mentioned', async () => {
+ const { asMember, channel, owner } = await fixture.createTeamChannel();
+ await fixture.addAgent(channel.id, 'Coder');
+
+ const message = await asMember.send(channel.id, {
+ content: 'Can you review this?',
+ mentions: [owner.id],
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+
+ expect(message).toMatchObject({ recipientMemberIds: [], routingStatus: 'directed' });
+ expect(await jobsOf(db, message.id)).toEqual([]);
+ });
+
+ it('leaves an unmentioned message to Jev, or to every Agent without a decision model', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const reviewer = await fixture.addAgent(channel.id, 'Reviewer');
+
+ const routed = await asMember.send(channel.id, {
+ content: 'Anyone?',
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+ expect(routed).toMatchObject({ routingAttempt: 1, routingStatus: 'pending' });
+ expect(await jobsOf(db, routed.id)).toEqual([]);
+
+ const broadcast = await asMember.send(channel.id, {
+ content: 'Everyone?',
+ requestKey: 'req-2',
+ routing: 'fallback',
+ });
+ expect(broadcast).toMatchObject({ routingSource: 'fallback', routingStatus: 'assigned' });
+ expect(broadcast.recipientMemberIds.sort()).toEqual([coder.id, reviewer.id].sort());
+ expect(await jobsOf(db, broadcast.id)).toHaveLength(2);
+ });
+
+ it('skips routing when no Agent can answer', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+
+ const message = await asMember.send(channel.id, {
+ content: 'Hello',
+ requestKey: 'req-1',
+ routing: 'jev',
+ });
+
+ expect(message.routingStatus).toBe('skipped');
+ });
+
+ it('routes inside a Thread to its followers and lets mentions join it', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const reviewer = await fixture.addAgent(channel.id, 'Reviewer');
+ const root = await asMember.send(channel.id, {
+ content: 'Root',
+ mentions: [coder.id],
+ requestKey: 'root',
+ routing: 'jev',
+ });
+ const [thread] = await db
+ .insert(channelThreads)
+ .values({
+ channelId: channel.id,
+ followerMemberIds: [coder.id],
+ rootMessageId: root.id,
+ rootSequence: root.sequence,
+ })
+ .returning();
+
+ const followUp = await asMember.send(channel.id, {
+ content: 'More',
+ requestKey: 'follow-up',
+ routing: 'fallback',
+ threadId: thread.id,
+ });
+ expect(followUp.recipientMemberIds).toEqual([coder.id]);
+
+ await asMember.send(channel.id, {
+ content: 'Join us',
+ mentions: [reviewer.id.toUpperCase(), reviewer.id],
+ requestKey: 'join',
+ routing: 'jev',
+ threadId: thread.id,
+ });
+ const [joined] = await db.select().from(channelThreads).where(eq(channelThreads.id, thread.id));
+ expect(joined.followerMemberIds).toEqual([coder.id, reviewer.id]);
+
+ const next = await asMember.send(channel.id, {
+ content: 'Everyone here',
+ requestKey: 'after-join',
+ routing: 'fallback',
+ threadId: thread.id,
+ });
+ expect(next.recipientMemberIds.sort()).toEqual([coder.id, reviewer.id].sort());
+ });
+
+ it('returns the original message on retry and rejects a reused retry key', async () => {
+ const { asMember, asOwner, channel } = await fixture.createTeamChannel();
+ const coder = await fixture.addAgent(channel.id, 'Coder');
+ const input = {
+ content: 'Once',
+ mentions: [coder.id.toUpperCase(), coder.id],
+ requestKey: 'req-1',
+ routing: 'jev' as const,
+ };
+
+ const first = await asMember.send(channel.id, input);
+ expect(first.mentions).toEqual([coder.id]);
+ const retried = await asMember.send(channel.id, { ...input, mentions: [coder.id] });
+ expect(retried.id).toBe(first.id);
+
+ await expect(
+ asMember.send(channel.id, { ...input, content: 'Different' }),
+ ).rejects.toMatchObject({ code: 'CONFLICT' });
+ await expect(asOwner.send(channel.id, input)).rejects.toMatchObject({ code: 'CONFLICT' });
+ });
+
+ it('rejects empty or oversized content, unknown mentions and foreign files', async () => {
+ const { asMember, channel } = await fixture.createTeamChannel();
+ const base = { requestKey: 'req-1', routing: 'jev' as const };
+
+ await expect(asMember.send(channel.id, { ...base, content: ' ' })).rejects.toMatchObject({
+ code: 'BAD_REQUEST',
+ });
+ await expect(
+ asMember.send(channel.id, {
+ ...base,
+ content: 'x'.repeat(CHANNEL_LIMITS.contentLength + 1),
+ }),
+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });
+ for (const mention of ['not-a-uuid', '00000000-0000-4000-8000-000000000001']) {
+ await expect(
+ asMember.send(channel.id, { ...base, content: 'Hi', mentions: [mention] }),
+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });
+ }
+ await expect(
+ asMember.send(channel.id, { ...base, content: 'Hi', fileIds: ['file_missing'] }),
+ ).rejects.toMatchObject({ code: 'BAD_REQUEST' });
+ });
+});
diff --git a/packages/database/src/repositories/channel/__tests__/testUtils.ts b/packages/database/src/repositories/channel/__tests__/testUtils.ts
new file mode 100644
index 00000000000..60c0082f25d
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/testUtils.ts
@@ -0,0 +1,144 @@
+import type { ChannelMemberConfig, ChannelMemberRole, ChannelRuntime } from '@lobechat/types';
+import { eq, inArray } from 'drizzle-orm';
+
+import {
+ agentOperations,
+ agents,
+ channelJobs,
+ channelMembers,
+ channels,
+ devices,
+ users,
+ workspaces,
+} from '../../../schemas';
+import type { LobeChatDatabase } from '../../../type';
+import { ChannelRepository } from '..';
+
+type AgentFixtureConfig = ChannelMemberConfig & {
+ model: string;
+ provider: string;
+ runtime: ChannelRuntime;
+};
+
+export const nativeConfig: AgentFixtureConfig = {
+ model: 'gpt-5',
+ provider: 'openai',
+ runtime: 'native',
+};
+
+/** `device-1` is public in the fixture workspace; any other device id needs a grant. */
+export const deviceConfig = (
+ workingDirectory = '/repo',
+ deviceId = 'device-1',
+ deviceOwnerId?: string,
+): AgentFixtureConfig => ({
+ deviceId,
+ deviceOwnerId,
+ model: 'gpt-5',
+ provider: 'openai',
+ runtime: 'codex',
+ workingDirectory,
+});
+
+export const lease = { serverDefaultAgentConfig: {}, leaseMs: 60_000, leaseOwner: 'worker-1' };
+
+/**
+ * Users and a workspace for one test file. Each file passes its own prefix so files can
+ * share a server database.
+ */
+export const createChannelFixture = (db: LobeChatDatabase, prefix: string) => {
+ const ownerId = `${prefix}-owner`;
+ const memberId = `${prefix}-member`;
+ const workspaceId = `${prefix}-workspace`;
+ const userIds = [ownerId, memberId];
+
+ const setup = async () => {
+ await db.insert(users).values([
+ { fullName: 'Olivia Owner', id: ownerId },
+ { id: memberId, username: 'mia' },
+ ]);
+ await db
+ .insert(workspaces)
+ .values({ id: workspaceId, name: 'Workspace', primaryOwnerId: ownerId, slug: workspaceId });
+ await db.insert(devices).values({
+ deviceId: 'device-1',
+ identitySource: 'fallback',
+ userId: ownerId,
+ visibility: 'public',
+ workspaceId,
+ });
+ };
+
+ const cleanup = async () => {
+ // Raw user deletion preserves Channel history; remove fixture-owned personal Channels too.
+ await db.delete(channels).where(inArray(channels.userId, userIds));
+ // Operations outlive their channel by design; drop the ones this fixture ran.
+ await db.delete(agentOperations).where(inArray(agentOperations.userId, userIds));
+ await db.delete(workspaces).where(eq(workspaces.id, workspaceId));
+ await db.delete(users).where(inArray(users.id, userIds));
+ };
+
+ const addAgent = async (channelId: string, name: string, config = nativeConfig) => {
+ const [channel] = await db.select().from(channels).where(eq(channels.id, channelId));
+ const [source] = await db
+ .insert(agents)
+ .values({
+ userId: ownerId,
+ workspaceId: channel.workspaceId,
+ name,
+ model: config.model,
+ provider: config.provider,
+ agencyConfig:
+ config.runtime === 'native'
+ ? undefined
+ : { heterogeneousProvider: { type: config.runtime } },
+ })
+ .returning();
+ return new ChannelRepository(db, ownerId, channel.workspaceId).addAgent(channelId, {
+ agentId: source.id,
+ config,
+ name,
+ });
+ };
+
+ const addPerson = async (channelId: string, userId: string, role: ChannelMemberRole) => {
+ const [person] = await db
+ .insert(channelMembers)
+ .values({ actorType: 'user', channelId, lastReadSequence: 0, role, userId })
+ .returning();
+ return person;
+ };
+
+ /** A workspace channel owned by `ownerId`, with `memberId` as a plain member. */
+ const createTeamChannel = async (title = 'Team') => {
+ const asOwner = new ChannelRepository(db, ownerId, workspaceId);
+ const { channel, member: owner } = await asOwner.create({ title });
+ const member = await addPerson(channel.id, memberId, 'member');
+
+ return {
+ asMember: new ChannelRepository(db, memberId, workspaceId),
+ asOwner,
+ channel,
+ member,
+ owner,
+ };
+ };
+
+ return { addAgent, addPerson, cleanup, createTeamChannel, memberId, ownerId, setup, workspaceId };
+};
+
+export const jobsOf = (db: LobeChatDatabase, messageId: string) =>
+ db.select().from(channelJobs).where(eq(channelJobs.messageId, messageId));
+
+export const jobById = async (db: LobeChatDatabase, jobId: string) => {
+ const [job] = await db.select().from(channelJobs).where(eq(channelJobs.id, jobId));
+ return job;
+};
+
+export const operationById = async (db: LobeChatDatabase, operationId: string | null) => {
+ const [operation] = await db
+ .select()
+ .from(agentOperations)
+ .where(eq(agentOperations.id, operationId!));
+ return operation;
+};
diff --git a/packages/database/src/repositories/channel/__tests__/topicContinuation.test.ts b/packages/database/src/repositories/channel/__tests__/topicContinuation.test.ts
new file mode 100644
index 00000000000..52e3a0fe055
--- /dev/null
+++ b/packages/database/src/repositories/channel/__tests__/topicContinuation.test.ts
@@ -0,0 +1,186 @@
+// @vitest-environment node
+import { eq } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../../core/getTestDB';
+import { agents, channelMembers, channelThreads, topics } from '../../../schemas';
+import { ChannelExecutionRepository } from '..';
+import { createChannelFixture, jobsOf, lease } from './testUtils';
+
+const db = await getTestDB();
+const fixture = createChannelFixture(db, 'channel-continuation');
+const execution = new ChannelExecutionRepository(db);
+beforeEach(fixture.setup);
+afterEach(fixture.cleanup);
+
+const setup = async (thread = false) => {
+ const team = await fixture.createTeamChannel();
+ const agent = await fixture.addAgent(team.channel.id, 'Agent');
+ let threadId: string | undefined;
+ if (thread) {
+ const root = await team.asMember.send(team.channel.id, {
+ content: 'Thread root',
+ mentions: [team.owner.id],
+ requestKey: 'root',
+ routing: 'fallback',
+ });
+ const [created] = await db
+ .insert(channelThreads)
+ .values({
+ channelId: team.channel.id,
+ rootMessageId: root.id,
+ rootSequence: root.sequence,
+ followerMemberIds: [agent.id],
+ })
+ .returning();
+ threadId = created.id;
+ }
+ let sequence = 0;
+ const send = async () => {
+ const content = `Request ${++sequence}`;
+ const message = await team.asMember.send(team.channel.id, {
+ content,
+ mentions: [agent.id],
+ requestKey: content,
+ routing: 'fallback',
+ threadId,
+ });
+ return (await jobsOf(db, message.id))[0];
+ };
+ const claim = (id: string) => execution.claim(team.channel.id, id, lease);
+ const finish = async (id: string, publish = true) => {
+ await execution.accepted(team.channel.id, id, {});
+ await execution.saveDraft(team.channel.id, id, `Answer ${sequence}`);
+ if (publish) await execution.publish(team.channel.id, id);
+ await execution.releaseWriter(team.channel.id, id);
+ };
+ const input = async (id: string) =>
+ (await execution.input(team.channel.id, id)).map((m) => m.content);
+ return { ...team, agent, claim, finish, input, send };
+};
+
+describe('Channel topic continuation', () => {
+ it.each([
+ { hours: 3, thread: false, reuse: true },
+ { hours: 5, thread: false, reuse: false },
+ { hours: 5, thread: true, reuse: true },
+ ])(
+ 'checks idle expiry on the next request: $hours hours, Thread=$thread',
+ async ({ hours, thread, reuse }) => {
+ const state = await setup(thread);
+ const first = (await state.claim((await state.send()).id))!;
+ await state.finish(first.job.id);
+ await db
+ .update(topics)
+ .set({ updatedAt: new Date(Date.now() - hours * 60 * 60 * 1000) })
+ .where(eq(topics.id, first.topic.id));
+ const second = (await state.claim((await state.send()).id))!;
+ expect(second.topic.id === first.topic.id).toBe(reuse);
+ expect(second.job.operationId).not.toBe(first.job.operationId);
+ expect(second.job.topicId).toBe(second.topic.id);
+ expect(await state.input(second.job.id)).toEqual(
+ reuse ? ['Request 2'] : ['Request 1', 'Answer 1', 'Request 2'],
+ );
+ expect(await db.select().from(topics).where(eq(topics.id, first.topic.id))).toHaveLength(1);
+ },
+ );
+
+ it.each(['environment', 'config', 'agent', 'trashed', 'failed', 'unknown'])(
+ 'starts a new topic after %s changes the continuation boundary',
+ async (reason) => {
+ const state = await setup();
+ const first = (await state.claim((await state.send()).id))!;
+ if (reason === 'failed') {
+ await execution.fail(state.channel.id, first.job.id, { message: 'Failed' });
+ await execution.releaseWriter(state.channel.id, first.job.id);
+ } else if (reason === 'unknown') {
+ await execution.executionUnknown(state.channel.id, first.job.id, 'Dispatch unknown');
+ await execution.isolate(state.channel.id, first.job.id, 'Unconfirmed');
+ } else {
+ await state.finish(first.job.id);
+ }
+ if (reason === 'environment')
+ await db
+ .update(channelMembers)
+ .set({
+ config: {
+ ...state.agent.config,
+ deviceId: 'device-1',
+ workingDirectory: '/different-repo',
+ },
+ })
+ .where(eq(channelMembers.id, state.agent.id));
+ if (reason === 'config')
+ await db
+ .update(agents)
+ .set({ model: 'changed' })
+ .where(eq(agents.id, state.agent.agentId!));
+ if (reason === 'agent') {
+ const [source] = await db
+ .insert(agents)
+ .values({ userId: fixture.ownerId, workspaceId: fixture.workspaceId })
+ .returning();
+ await db
+ .update(channelMembers)
+ .set({ agentId: source.id })
+ .where(eq(channelMembers.id, state.agent.id));
+ }
+ if (reason === 'trashed')
+ await db
+ .update(topics)
+ .set({ isDeleted: true, deletedAt: new Date() })
+ .where(eq(topics.id, first.topic.id));
+ const second = (await state.claim((await state.send()).id))!;
+ expect(second.topic.id).not.toBe(first.topic.id);
+ expect(second.job.manifest?.afterSequence).toBe(0);
+ },
+ );
+
+ it('excludes delayed public copies of answers already in the topic, even across queued requests', async () => {
+ const state = await setup();
+ const first = (await state.claim((await state.send()).id))!;
+ const next = await state.send();
+ await state.finish(first.job.id, false);
+ const second = (await state.claim(next.id))!;
+ expect(second.topic.id).toBe(first.topic.id);
+ await execution.publish(state.channel.id, first.job.id);
+ expect(await state.input(second.job.id)).toEqual(['Request 2']);
+ await state.finish(second.job.id);
+ const third = (await state.claim((await state.send()).id))!;
+ expect(await state.input(third.job.id)).toEqual(['Request 3']);
+ });
+
+ it('continues the most recently claimed delivery after an older request is routed late', async () => {
+ const state = await setup();
+ const early = await state.asMember.send(state.channel.id, {
+ content: 'Delayed request',
+ requestKey: 'delayed',
+ routing: 'jev',
+ });
+ const first = (await state.claim((await state.send()).id))!;
+ await state.finish(first.job.id);
+ await execution.resolveRouting(state.channel.id, early.id, early.routingAttempt, {
+ memberIds: [state.agent.id],
+ reason: 'Agent can help',
+ status: 'assigned',
+ });
+ const [delayedJob] = await jobsOf(db, early.id);
+ const delayed = (await state.claim(delayedJob.id))!;
+ expect(delayed.topic.id).not.toBe(first.topic.id);
+ await state.finish(delayed.job.id);
+ const next = (await state.claim((await state.send()).id))!;
+ expect(next.topic.id).toBe(delayed.topic.id);
+ expect(await state.input(next.job.id)).toEqual(['Request 1', 'Answer 1', 'Request 2']);
+ });
+
+ it('blocks a deleted Agent reference while retaining the public request', async () => {
+ const state = await setup();
+ const job = await state.send();
+ await db.delete(agents).where(eq(agents.id, state.agent.agentId!));
+ expect(await state.claim(job.id)).toBeNull();
+ expect((await jobsOf(db, job.messageId))[0]).toMatchObject({
+ blockedCode: 'unavailable',
+ topicId: null,
+ });
+ });
+});
diff --git a/packages/database/src/repositories/channel/agent.ts b/packages/database/src/repositories/channel/agent.ts
new file mode 100644
index 00000000000..7bef2198fde
--- /dev/null
+++ b/packages/database/src/repositories/channel/agent.ts
@@ -0,0 +1,140 @@
+import { DEFAULT_PROVIDER } from '@lobechat/business-const';
+import { isHeterogeneousAgentModelId } from '@lobechat/const';
+import type { ChannelExecutionConfig, ChannelMemberConfig, LobeAgentConfig } from '@lobechat/types';
+import { agentDisplayName, isChannelRuntime } from '@lobechat/types';
+import { cleanObject } from '@lobechat/utils';
+import { and, eq } from 'drizzle-orm';
+import type { PartialDeep } from 'type-fest';
+
+import type { ChannelItem, ChannelMemberItem } from '../../schemas';
+import { agents, channelMembers, userSettings } from '../../schemas';
+import type { Transaction } from '../../type';
+import { agentUsableByWhere } from '../../utils/agent-access';
+import { mergeAgentDefaultConfig } from '../../utils/agentConfig';
+import { ChannelError } from './error';
+
+/** Explicitly select environment fields so legacy or untyped copies cannot override an Agent. */
+const environment = (config?: ChannelMemberConfig | null): ChannelMemberConfig =>
+ cleanObject({
+ deviceId: config?.deviceId,
+ deviceOwnerId: config?.deviceOwnerId,
+ workingDirectory: config?.workingDirectory,
+ });
+
+export interface ChannelAddAgentInput {
+ agentId: string;
+ config?: ChannelMemberConfig;
+ /** Optional Channel-specific routing description and identity label. */
+ description?: string;
+ name?: string;
+}
+
+/** Check Agent scope and hold it through creation of the Channel/member reference. */
+export const requireChannelAgent = async (
+ tx: Transaction,
+ workspaceId: string | null,
+ userId: string,
+ agentId: string,
+) => {
+ const [agent] = await tx
+ .select({ name: agents.name, title: agents.title })
+ .from(agents)
+ .where(agentUsableByWhere(agentId, { userId, workspaceId: workspaceId ?? undefined }))
+ .for('share');
+ if (!agent) throw new ChannelError('NOT_FOUND', 'Agent not found');
+ return agent;
+};
+
+/** Called under the Channel lock after the caller's admin role has been checked. */
+export const addAgentMember = async (
+ tx: Transaction,
+ channel: ChannelItem,
+ userId: string,
+ input: ChannelAddAgentInput,
+): Promise<ChannelMemberItem> => {
+ if (channel.agentId) {
+ if (input.agentId !== channel.agentId)
+ throw new ChannelError('BAD_REQUEST', 'A direct conversation is bound to one Agent');
+ const [existing] = await tx
+ .select({ id: channelMembers.id })
+ .from(channelMembers)
+ .where(and(eq(channelMembers.channelId, channel.id), eq(channelMembers.actorType, 'agent')));
+ if (existing)
+ throw new ChannelError('CONFLICT', 'The direct conversation already has its Agent');
+ }
+ if (!input.agentId.trim())
+ throw new ChannelError('BAD_REQUEST', 'An Agent reference is required');
+ const agent = await requireChannelAgent(tx, channel.workspaceId, userId, input.agentId);
+ const [member] = await tx
+ .insert(channelMembers)
+ .values({
+ actorType: 'agent',
+ agentId: input.agentId,
+ channelId: channel.id,
+ config: environment(input.config),
+ description: input.description,
+ name: input.name?.trim() || agentDisplayName(agent, 'Agent'),
+ })
+ .returning();
+ return member;
+};
+
+/** Read current settings with the requester's Agent permissions, then freeze the effective config. */
+export const resolveExecutionConfig = async (
+ tx: Transaction,
+ channel: ChannelItem,
+ member: ChannelMemberItem,
+ userId: string,
+ serverDefault: PartialDeep<LobeAgentConfig>,
+): Promise<ChannelExecutionConfig | null> => {
+ if (!member.agentId) return null;
+ const [agent] = await tx
+ .select({
+ agencyConfig: agents.agencyConfig,
+ avatar: agents.avatar,
+ backgroundColor: agents.backgroundColor,
+ chatConfig: agents.chatConfig,
+ editorData: agents.editorData,
+ fewShots: agents.fewShots,
+ model: agents.model,
+ name: agents.name,
+ openingMessage: agents.openingMessage,
+ openingQuestions: agents.openingQuestions,
+ params: agents.params,
+ plugins: agents.plugins,
+ profile: agents.profile,
+ provider: agents.provider,
+ systemRole: agents.systemRole,
+ title: agents.title,
+ tts: agents.tts,
+ virtual: agents.virtual,
+ })
+ .from(agents)
+ .where(
+ agentUsableByWhere(member.agentId, { userId, workspaceId: channel.workspaceId ?? undefined }),
+ )
+ .for('share');
+ if (!agent) return null;
+ const [settings] = channel.workspaceId
+ ? []
+ : await tx
+ .select({ defaultAgent: userSettings.defaultAgent })
+ .from(userSettings)
+ .where(eq(userSettings.id, userId));
+ const config = mergeAgentDefaultConfig(agent, {
+ serverDefault,
+ userDefault: settings?.defaultAgent,
+ workspaceId: channel.workspaceId,
+ });
+ // Match ordinary Agent execution, including Agents created before agencyConfig existed.
+ const runtime =
+ config.agencyConfig?.heterogeneousProvider?.type ??
+ (isHeterogeneousAgentModelId(config.model) ? config.model : 'native');
+ if (!isChannelRuntime(runtime)) return null;
+ return {
+ ...config,
+ ...environment(member.config),
+ provider: config.provider || DEFAULT_PROVIDER,
+ runtime,
+ };
+};
diff --git a/packages/database/src/repositories/channel/attachments.ts b/packages/database/src/repositories/channel/attachments.ts
new file mode 100644
index 00000000000..2ab16f84989
--- /dev/null
+++ b/packages/database/src/repositories/channel/attachments.ts
@@ -0,0 +1,52 @@
+import type { SQLWrapper } from 'drizzle-orm';
+import { asc, inArray } from 'drizzle-orm';
+
+import { channelMessageFiles } from '../../schemas';
+import type { LobeChatDatabase, Transaction } from '../../type';
+
+/**
+ * Records a new message's attachments in the order the sender gave them. Performs no access
+ * check: the caller must already have authorized every file for the sender
+ * (`sendMessage` in `send.ts` does, under the channel lock).
+ */
+export const attachFiles = async (
+ tx: Transaction,
+ params: { fileIds: string[]; messageId: string },
+) => {
+ const { fileIds, messageId } = params;
+ if (!fileIds.length) return;
+
+ await tx.insert(channelMessageFiles).values(
+ fileIds.map((fileId, sortOrder) => ({
+ fileId,
+ messageId,
+ sortOrder,
+ })),
+ );
+};
+
+/**
+ * Attachment ids per message, in attachment order. A file deleted since the message was sent
+ * is no longer listed: the cascade removed its row. Pass a subquery rather than an id list when
+ * the message set is unbounded, such as a whole branch.
+ */
+export const fileIdsByMessage = async (
+ tx: LobeChatDatabase | Transaction,
+ messageIds: string[] | SQLWrapper,
+) => {
+ const result = new Map<string, string[]>();
+ if (Array.isArray(messageIds) && !messageIds.length) return result;
+
+ const rows = await tx
+ .select({ fileId: channelMessageFiles.fileId, messageId: channelMessageFiles.messageId })
+ .from(channelMessageFiles)
+ .where(inArray(channelMessageFiles.messageId, messageIds))
+ .orderBy(asc(channelMessageFiles.messageId), asc(channelMessageFiles.sortOrder));
+ for (const { fileId, messageId } of rows) {
+ const list = result.get(messageId);
+ if (list) list.push(fileId);
+ else result.set(messageId, [fileId]);
+ }
+
+ return result;
+};
diff --git a/packages/database/src/repositories/channel/claim.ts b/packages/database/src/repositories/channel/claim.ts
new file mode 100644
index 00000000000..ed3cb3ed13a
--- /dev/null
+++ b/packages/database/src/repositories/channel/claim.ts
@@ -0,0 +1,314 @@
+import type { ChannelJobBlockCode, LobeAgentConfig } from '@lobechat/types';
+import { and, asc, eq, isNotNull, isNull, sql } from 'drizzle-orm';
+import type { PartialDeep } from 'type-fest';
+
+import type { ChannelItem, ChannelJobItem, ChannelMemberItem, TopicItem } from '../../schemas';
+import {
+ agentOperations,
+ channelJobs,
+ channelMemberGrants,
+ channelMembers,
+ channelMessages,
+ devices,
+} from '../../schemas';
+import type { Transaction } from '../../type';
+import { createNanoId } from '../../utils/idGenerator';
+import { resolveExecutionConfig } from './agent';
+import { findThread } from './delivery';
+import { buildManifest } from './manifest';
+import { resolveTopic } from './topic';
+import { audit } from './transaction';
+
+export interface ChannelClaimOptions {
+ /** How long the claimer may go without a heartbeat before reconcile takes over. */
+ leaseMs: number;
+ /** Process or queue worker that will drive the run. */
+ leaseOwner: string;
+ /** Trusted server defaults from getServerDefaultAgentConfig(); use {} when unconfigured. */
+ serverDefaultAgentConfig: PartialDeep<LobeAgentConfig>;
+}
+
+export interface ChannelClaim {
+ /** The claimed job, with its reserved `operationId` and frozen `manifest`. */
+ job: ChannelJobItem;
+ member: ChannelMemberItem;
+ /** Ordinary Agent topic, reused when safe; also the operation's `topicId`. */
+ topic: TopicItem;
+}
+
+const DIRECTORY_LOCK = 'channel_jobs_active_directory_unique';
+
+const uniqueViolation = (error: unknown): string | undefined => {
+ const pgError = error as {
+ cause?: { code?: string; constraint?: string };
+ code?: string;
+ constraint?: string;
+ };
+ const code = pgError.cause?.code ?? pgError.code;
+ return code === '23505' ? (pgError.cause?.constraint ?? pgError.constraint ?? '') : undefined;
+};
+
+/** Records why a queued job cannot start; clients read the code, never the text. */
+const block = async (
+ tx: Transaction,
+ job: ChannelJobItem,
+ code: ChannelJobBlockCode,
+ reason: string,
+) => {
+ if (job.blockedCode === code && job.blockedReason === reason) return;
+
+ await tx
+ .update(channelJobs)
+ .set({ blockedCode: code, blockedReason: reason })
+ .where(eq(channelJobs.id, job.id));
+ await audit(tx, job.channelId, 'job_blocked', job.id, { code, reason });
+};
+
+/** Settles a job that must never run, e.g. its requester left or its environment changed. */
+const cancel = async (tx: Transaction, job: ChannelJobItem, reason: string) => {
+ await tx
+ .update(channelJobs)
+ .set({ blockedCode: null, blockedReason: null, status: 'cancelled' })
+ .where(eq(channelJobs.id, job.id));
+ await audit(tx, job.channelId, 'job_cancelled', job.id, { reason });
+};
+
+type Block = { code: ChannelJobBlockCode; reason: string };
+
+const APPROVAL_PENDING: Block = {
+ code: 'device_approval_pending',
+ reason: 'Waiting for the device owner to approve',
+};
+
+/**
+ * Whether the member may run on its device. Fails closed: outside a personal channel, a
+ * device that is not public in this workspace needs an approved grant for exactly the
+ * member's current device and directory. A missing grant (never
+ * requested, or deleted with the owner's account) blocks like a pending one.
+ */
+const deviceBlock = async (
+ tx: Transaction,
+ channel: ChannelItem,
+ member: ChannelMemberItem,
+): Promise<Block | undefined> => {
+ const { deviceId, deviceOwnerId, workingDirectory } = member.config ?? {};
+ if (workingDirectory && !deviceId)
+ return { code: 'unavailable', reason: 'A working directory requires a device' };
+ if (!deviceId) return;
+
+ if (!channel.workspaceId)
+ return deviceOwnerId && deviceOwnerId === channel.userId
+ ? undefined
+ : { code: 'unavailable', reason: 'The device does not belong to this channel owner' };
+
+ const [shared] = await tx
+ .select({ id: devices.id })
+ .from(devices)
+ .where(
+ and(
+ eq(devices.deviceId, deviceId),
+ eq(devices.workspaceId, channel.workspaceId),
+ eq(devices.visibility, 'public'),
+ ),
+ )
+ .limit(1);
+ if (shared) return;
+
+ if (!deviceOwnerId || !workingDirectory) return APPROVAL_PENDING;
+ const [grant] = await tx
+ .select()
+ .from(channelMemberGrants)
+ .where(eq(channelMemberGrants.memberId, member.id));
+ if (
+ !grant ||
+ grant.deviceId !== deviceId ||
+ grant.deviceOwnerId !== deviceOwnerId ||
+ grant.workingDirectory !== workingDirectory
+ )
+ return APPROVAL_PENDING;
+ if (grant.status === 'pending') return APPROVAL_PENDING;
+ if (grant.status !== 'approved')
+ return { code: 'unavailable', reason: 'The device owner did not allow this environment' };
+};
+
+/** Another channel's live writer in the same device directory. */
+const directoryBlock = async (
+ tx: Transaction,
+ member: ChannelMemberItem,
+): Promise<Block | undefined> => {
+ const { deviceId, workingDirectory } = member.config ?? {};
+ if (!deviceId || !workingDirectory) return;
+
+ const [busy] = await tx
+ .select({ id: channelJobs.id })
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.deviceId, deviceId),
+ eq(channelJobs.workingDirectory, workingDirectory),
+ eq(channelJobs.writerHeld, true),
+ ),
+ )
+ .limit(1);
+ if (busy) return { code: 'directory_locked', reason: 'Another run is using this directory' };
+};
+
+/**
+ * Starts the job if it is at the head of its member's queue and nothing holds the member,
+ * its environment or its directory. The caller holds the channel lock. Returns null when
+ * the job cannot start now; a lasting reason is recorded on the job as `blockedCode`.
+ */
+export const claimJob = async (
+ tx: Transaction,
+ channel: ChannelItem,
+ jobId: string,
+ options: ChannelClaimOptions,
+): Promise<ChannelClaim | null> => {
+ if (channel.archived) return null;
+
+ const [job] = await tx
+ .select()
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.channelId, channel.id),
+ eq(channelJobs.id, jobId),
+ eq(channelJobs.status, 'queued'),
+ ),
+ );
+ if (!job) return null;
+
+ // Each member answers in message order.
+ const [head] = await tx
+ .select({ id: channelJobs.id })
+ .from(channelJobs)
+ .innerJoin(channelMessages, eq(channelMessages.id, channelJobs.messageId))
+ .where(and(eq(channelJobs.memberId, job.memberId), eq(channelJobs.status, 'queued')))
+ .orderBy(asc(channelMessages.sequence), asc(channelJobs.createdAt))
+ .limit(1);
+ if (head?.id !== job.id) return null;
+
+ const [member] = await tx
+ .select()
+ .from(channelMembers)
+ .where(and(eq(channelMembers.id, job.memberId), eq(channelMembers.active, true)));
+ if (!member?.config) return null;
+
+ const [busy] = await tx
+ .select({ id: channelJobs.id })
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.memberId, member.id),
+ eq(channelJobs.writerHeld, true),
+ isNull(channelJobs.isolatedAt),
+ ),
+ )
+ .limit(1);
+ if (busy) return null;
+
+ const [request] = await tx
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, job.messageId));
+ // The requester is the execution identity; without them there is nobody to run as.
+ const [requester] = await tx
+ .select({ id: channelMembers.id, userId: channelMembers.userId })
+ .from(channelMembers)
+ .where(
+ and(
+ eq(channelMembers.id, job.requesterMemberId),
+ eq(channelMembers.actorType, 'user'),
+ eq(channelMembers.active, true),
+ isNotNull(channelMembers.userId),
+ ),
+ );
+ if (!requester?.userId) {
+ await cancel(tx, job, 'requester_unavailable');
+ return null;
+ }
+
+ const executionConfig = await resolveExecutionConfig(
+ tx,
+ channel,
+ member,
+ requester.userId,
+ options.serverDefaultAgentConfig,
+ );
+ if (!executionConfig) {
+ await block(tx, job, 'unavailable', 'The Agent is unavailable');
+ return null;
+ }
+
+ const blocked = (await deviceBlock(tx, channel, member)) ?? (await directoryBlock(tx, member));
+ if (blocked) {
+ await block(tx, job, blocked.code, blocked.reason);
+ return null;
+ }
+
+ const thread = await findThread(tx, channel.id, job.threadId);
+
+ const now = new Date();
+ let claimed: Omit<ChannelClaim, 'member'>;
+ try {
+ // A savepoint, so losing the directory race to another channel keeps this transaction
+ // and leaves no topic or operation behind.
+ claimed = await tx.transaction(async (savepoint) => {
+ const { topic, afterSequence } = await resolveTopic(
+ savepoint,
+ channel,
+ job,
+ member,
+ requester.userId!,
+ request.sequence,
+ executionConfig,
+ );
+ const manifest = buildManifest({ afterSequence, job, member, request, thread });
+ const operationId = `op_${createNanoId(16)()}`;
+ await savepoint.insert(agentOperations).values({
+ id: operationId,
+ userId: requester.userId!,
+ workspaceId: channel.workspaceId,
+ topicId: topic.id,
+ agentId: member.agentId,
+ trigger: 'channel',
+ status: 'idle',
+ model: executionConfig.model,
+ provider: executionConfig.provider,
+ });
+ const [updated] = await savepoint
+ .update(channelJobs)
+ .set({
+ claimedAt: sql`clock_timestamp()`,
+ blockedCode: null,
+ blockedReason: null,
+ deviceId: member.config!.deviceId,
+ executionConfig,
+ leaseExpiresAt: new Date(now.getTime() + options.leaseMs),
+ leaseOwner: options.leaseOwner,
+ manifest,
+ operationId,
+ topicId: topic.id,
+ status: 'running',
+ workingDirectory: member.config!.workingDirectory,
+ writerHeld: true,
+ })
+ .where(eq(channelJobs.id, job.id))
+ .returning();
+ return { job: updated, topic };
+ });
+ } catch (error) {
+ const constraint = uniqueViolation(error);
+ if (constraint === undefined) throw error;
+ if (constraint === DIRECTORY_LOCK)
+ await block(tx, job, 'directory_locked', 'Another run is using this directory');
+ return null;
+ }
+
+ await audit(tx, channel.id, 'run_claimed', job.id, {
+ cutoff: claimed.job.manifest!.cutoffSequence,
+ operationId: claimed.job.operationId,
+ });
+
+ return { ...claimed, member };
+};
diff --git a/packages/database/src/repositories/channel/delivery.ts b/packages/database/src/repositories/channel/delivery.ts
new file mode 100644
index 00000000000..050ddf6e17d
--- /dev/null
+++ b/packages/database/src/repositories/channel/delivery.ts
@@ -0,0 +1,136 @@
+import { and, eq, inArray, sql } from 'drizzle-orm';
+
+import type {
+ ChannelMemberItem,
+ ChannelMessageItem,
+ ChannelThreadItem,
+ NewChannelMessage,
+} from '../../schemas';
+import {
+ channelJobs,
+ channelMembers,
+ channelMessages,
+ channels,
+ channelThreads,
+} from '../../schemas';
+import type { Transaction } from '../../type';
+import { ChannelError } from './error';
+
+/** The Thread a message belongs to, or null for the main channel. */
+export const findThread = async (
+ tx: Transaction,
+ channelId: string,
+ threadId?: string | null,
+): Promise<ChannelThreadItem | null> => {
+ if (!threadId) return null;
+
+ const [thread] = await tx
+ .select()
+ .from(channelThreads)
+ .where(and(eq(channelThreads.channelId, channelId), eq(channelThreads.id, threadId)));
+ if (!thread) throw new ChannelError('NOT_FOUND', 'Thread not found');
+
+ return thread;
+};
+
+/** Active members by id. Throws when any of them is missing or has left. */
+export const activeMembers = async (
+ tx: Transaction,
+ channelId: string,
+ memberIds: string[],
+): Promise<ChannelMemberItem[]> => {
+ const unique = [...new Set(memberIds)];
+ if (!unique.length) return [];
+
+ const members = await tx
+ .select()
+ .from(channelMembers)
+ .where(
+ and(
+ eq(channelMembers.channelId, channelId),
+ eq(channelMembers.active, true),
+ inArray(channelMembers.id, unique),
+ ),
+ );
+ if (members.length !== unique.length)
+ throw new ChannelError('BAD_REQUEST', 'A selected member is unavailable');
+
+ return members;
+};
+
+/**
+ * Agents that may answer a message without @mentions: every active Agent on the main
+ * channel, the following Agents inside a Thread.
+ */
+export const candidateAgents = async (
+ tx: Transaction,
+ channelId: string,
+ thread: ChannelThreadItem | null,
+): Promise<ChannelMemberItem[]> => {
+ const agents = await tx
+ .select()
+ .from(channelMembers)
+ .where(
+ and(
+ eq(channelMembers.channelId, channelId),
+ eq(channelMembers.actorType, 'agent'),
+ eq(channelMembers.active, true),
+ ),
+ );
+
+ return thread ? agents.filter((agent) => thread.followerMemberIds.includes(agent.id)) : agents;
+};
+
+/**
+ * Queues one job per Agent. Idempotent through the delivery key. Skips Agents whose
+ * environment changed after the message, so a late route cannot run an old instruction
+ * in a new directory. Returns the ids of the Agents that received a job.
+ */
+export const deliver = async (
+ tx: Transaction,
+ message: ChannelMessageItem,
+ agents: ChannelMemberItem[],
+ requesterMemberId: string,
+): Promise<string[]> => {
+ const recipients = agents.filter((agent) => agent.actorType === 'agent');
+ if (!recipients.length) return [];
+
+ await tx
+ .insert(channelJobs)
+ .values(
+ recipients.map((agent) => ({
+ channelId: message.channelId,
+ memberId: agent.id,
+ messageId: message.id,
+ requesterMemberId,
+ threadId: message.threadId,
+ })),
+ )
+ .onConflictDoNothing();
+
+ return recipients.map((agent) => agent.id);
+};
+
+/** Appends a message at the next channel sequence. The caller holds the channel lock. */
+export const appendMessage = async (
+ tx: Transaction,
+ values: Omit<NewChannelMessage, 'sequence' | 'id'> & { id?: string },
+): Promise<ChannelMessageItem> => {
+ const isReply = values.routingStatus === 'reply';
+ if (isReply ? !values.agentId || values.userId != null : !values.userId || values.agentId != null)
+ throw new ChannelError(
+ 'BAD_REQUEST',
+ 'A message requires exactly one sender of the correct type',
+ );
+ const [{ sequence }] = await tx
+ .update(channels)
+ .set({ sequence: sql`${channels.sequence} + 1` })
+ .where(eq(channels.id, values.channelId))
+ .returning({ sequence: channels.sequence });
+ const [message] = await tx
+ .insert(channelMessages)
+ .values({ ...values, sequence })
+ .returning();
+
+ return message;
+};
diff --git a/packages/database/src/repositories/channel/error.ts b/packages/database/src/repositories/channel/error.ts
new file mode 100644
index 00000000000..9e3011b6be1
--- /dev/null
+++ b/packages/database/src/repositories/channel/error.ts
@@ -0,0 +1,11 @@
+export type ChannelErrorCode = 'BAD_REQUEST' | 'CONFLICT' | 'FORBIDDEN' | 'NOT_FOUND';
+
+export class ChannelError extends Error {
+ constructor(
+ readonly code: ChannelErrorCode,
+ message: string,
+ ) {
+ super(message);
+ this.name = 'ChannelError';
+ }
+}
diff --git a/packages/database/src/repositories/channel/execution.ts b/packages/database/src/repositories/channel/execution.ts
new file mode 100644
index 00000000000..e79cf9a14ab
--- /dev/null
+++ b/packages/database/src/repositories/channel/execution.ts
@@ -0,0 +1,357 @@
+import type {
+ AgentOperationStatus,
+ ChannelContextMessage,
+ ChannelJobStatus,
+} from '@lobechat/types';
+import { and, eq, gt, isNotNull, sql } from 'drizzle-orm';
+
+import type { ChannelJobItem } from '../../schemas';
+import { agentOperations, agents, channelJobs, channelMembers, topics } from '../../schemas';
+import type { LobeChatDatabase, Transaction } from '../../type';
+import type { ChannelClaim, ChannelClaimOptions } from './claim';
+import { claimJob } from './claim';
+import { appendMessage } from './delivery';
+import { ChannelError } from './error';
+import { readManifestMessages } from './manifest';
+import type { ChannelRoutingDecision } from './routing';
+import { resolveRouting } from './routing';
+import type { ChannelStopScope } from './stop';
+import { stopScope } from './stop';
+import { audit, withChannelLock } from './transaction';
+import { advanceOperation, isolateWriter, isOpenJob, operationStatus } from './writer';
+
+/**
+ * A claimed job under the channel lock. A revoked job may still record its termination
+ * (`allowRevoked`) but never accept input or publish.
+ *
+ * A claim is recognized by its frozen manifest, not its operation reference: that reference is
+ * cleared if the operation row is deleted, and the writer must stay releasable even then.
+ */
+const claimed = async (
+ tx: Transaction,
+ channelId: string,
+ jobId: string,
+ allowRevoked = false,
+): Promise<ChannelJobItem> => {
+ const [job] = await tx
+ .select()
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.channelId, channelId),
+ eq(channelJobs.id, jobId),
+ isNotNull(channelJobs.manifest),
+ ),
+ );
+ if (!job) throw new ChannelError('NOT_FOUND', 'Claimed job not found');
+ if (!allowRevoked && job.publicationRevoked)
+ throw new ChannelError('CONFLICT', 'Run authority was revoked');
+
+ return job;
+};
+
+/**
+ * How a job ends once its writer is physically released.
+ *
+ * - Published: completed.
+ * - Failed (including an unknown execution or isolation): stays failed; nothing publishes. An
+ * unknown execution is never redelivered.
+ * - Revoked (stopped or isolated): an open job is cancelled.
+ * - Accepted draft not yet published: still running, so a retried publish can finish it.
+ * - Anything else ended without a reply: failed.
+ */
+export const releaseOutcome = (
+ job: ChannelJobItem,
+): {
+ error?: string;
+ job?: Extract<ChannelJobStatus, 'cancelled' | 'failed'>;
+ operation: AgentOperationStatus;
+ revoke: boolean;
+} => {
+ if (job.publishedMessageId) return { operation: 'done', revoke: false };
+ if (job.status === 'failed') return { job: 'failed', operation: 'error', revoke: true };
+ if (job.publicationRevoked) return { job: 'cancelled', operation: 'interrupted', revoke: true };
+ if (job.acceptedAt && job.draft !== null) return { operation: 'done', revoke: false };
+
+ return {
+ error: 'The run ended without a reply',
+ job: 'failed',
+ operation: 'error',
+ revoke: true,
+ };
+};
+
+/**
+ * Channel writes made by the system rather than by a person: the dispatcher, native
+ * completion callbacks, device receipts and reconcile. Mutations lock the channel row
+ * within a transaction, except lease-only heartbeats. Callers must authenticate the source
+ * (job-scoped token, service credentials) before calling.
+ */
+export class ChannelExecutionRepository {
+ constructor(private readonly db: LobeChatDatabase) {}
+
+ /** Writes back a Jev decision for `attempt`; false when the result is stale. */
+ resolveRouting = async (
+ channelId: string,
+ messageId: string,
+ attempt: number,
+ decision: ChannelRoutingDecision,
+ ) =>
+ withChannelLock(this.db, channelId, (tx) =>
+ resolveRouting(tx, channelId, messageId, attempt, decision),
+ );
+
+ /** Starts a queued job; null when it cannot start now. See {@link claimJob}. */
+ claim = async (
+ channelId: string,
+ jobId: string,
+ options: ChannelClaimOptions,
+ ): Promise<ChannelClaim | null> =>
+ withChannelLock(this.db, channelId, (tx, channel) => claimJob(tx, channel, jobId, options));
+
+ /**
+ * What a claimed job's run receives: its branch up to the request, oldest first. Reads
+ * without the channel lock, since nothing at or before the cutoff changes after the claim.
+ */
+ input = async (channelId: string, jobId: string): Promise<ChannelContextMessage[]> => {
+ const [job] = await this.db
+ .select({ manifest: channelJobs.manifest, topicId: channelJobs.topicId })
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.channelId, channelId),
+ eq(channelJobs.id, jobId),
+ isNotNull(channelJobs.manifest),
+ ),
+ );
+ if (!job?.manifest) throw new ChannelError('NOT_FOUND', 'Claimed job not found');
+
+ return readManifestMessages(this.db, channelId, job.manifest, job.topicId);
+ };
+
+ /** The runtime took the input; only now may the job publish. */
+ accepted = async (
+ channelId: string,
+ jobId: string,
+ receipt: { nativeSessionId?: string; nativeTurnId?: string },
+ ) =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId);
+ if (job.acceptedAt || !job.writerHeld || job.status !== 'running') return;
+
+ await tx
+ .update(channelJobs)
+ .set({ acceptedAt: new Date() })
+ .where(eq(channelJobs.id, job.id));
+
+ if (job.operationId) {
+ const [operation] = await tx
+ .select({ topicId: agentOperations.topicId })
+ .from(agentOperations)
+ .where(eq(agentOperations.id, job.operationId));
+ if (
+ receipt.nativeSessionId &&
+ job.executionConfig?.runtime !== 'native' &&
+ operation?.topicId
+ )
+ await tx
+ .update(topics)
+ .set({
+ metadata: sql`coalesce(${topics.metadata}, '{}'::jsonb) || ${JSON.stringify({ heteroSessionId: receipt.nativeSessionId })}::jsonb`,
+ })
+ .where(eq(topics.id, operation.topicId));
+ if (receipt.nativeTurnId)
+ await tx
+ .update(agentOperations)
+ .set({
+ metadata: sql`coalesce(${agentOperations.metadata}, '{}'::jsonb) || ${JSON.stringify({ nativeTurnId: receipt.nativeTurnId })}::jsonb`,
+ })
+ .where(eq(agentOperations.id, job.operationId));
+ }
+ await advanceOperation(tx, job, 'running');
+ await audit(tx, channelId, 'input_accepted', job.id, {
+ cutoff: job.manifest?.cutoffSequence ?? null,
+ });
+ });
+
+ /** Stores the final answer. Immutable once saved, so a retry cannot change it. */
+ saveDraft = async (channelId: string, jobId: string, content: string) =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId);
+ if (job.draft !== null) {
+ if (job.draft !== content)
+ throw new ChannelError('CONFLICT', 'The final draft is immutable');
+ return;
+ }
+ await tx.update(channelJobs).set({ draft: content }).where(eq(channelJobs.id, job.id));
+ });
+
+ /**
+ * Publishes the saved draft as the member's reply and completes the job. Idempotent: a
+ * second call returns the same message id.
+ */
+ publish = async (channelId: string, jobId: string): Promise<string> =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId);
+ if (job.publishedMessageId) return job.publishedMessageId;
+ if (job.draft === null || !job.acceptedAt)
+ throw new ChannelError('CONFLICT', 'No accepted final draft');
+
+ const [member] = await tx
+ .select({ id: channelMembers.id })
+ .from(channelMembers)
+ .where(and(eq(channelMembers.id, job.memberId), eq(channelMembers.active, true)));
+ if (!member) throw new ChannelError('CONFLICT', 'The member left the channel');
+
+ // The member may have been rebound since claim; attribute the reply to its frozen Agent.
+ const [sender] = await tx
+ .select({ id: agents.id })
+ .from(agents)
+ .where(eq(agents.id, job.manifest!.self.agentId))
+ .for('share');
+ if (!sender) throw new ChannelError('CONFLICT', 'The replying Agent was deleted');
+
+ const reply = await appendMessage(tx, {
+ agentId: sender.id,
+ channelId,
+ content: job.draft,
+ replyToId: job.messageId,
+ requestKey: `job:${job.id}`,
+ routingStatus: 'reply',
+ threadId: job.threadId,
+ });
+ await tx
+ .update(channelJobs)
+ .set({ publishedMessageId: reply.id, status: 'completed' })
+ .where(eq(channelJobs.id, job.id));
+ await audit(tx, channelId, 'draft_published', job.id, { messageId: reply.id });
+
+ return reply.id;
+ });
+
+ /**
+ * Physical termination confirmed (process tree ended, or the native operation finished).
+ * Releases the writer, and with it the member and the device directory; the only other
+ * release is a trusted `notSubmitted` failure, where nothing ran.
+ * Settles the job and its operation by how the run ended; see {@link releaseOutcome}.
+ */
+ releaseWriter = async (channelId: string, jobId: string) =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId, true);
+ if (!job.writerHeld) return;
+
+ const outcome = releaseOutcome(job);
+ const status = outcome.job && isOpenJob(job) ? outcome.job : job.status;
+ await tx
+ .update(channelJobs)
+ .set({
+ leaseExpiresAt: null,
+ leaseOwner: null,
+ publicationRevoked: outcome.revoke || job.publicationRevoked,
+ status,
+ writerHeld: false,
+ })
+ .where(eq(channelJobs.id, job.id));
+ await advanceOperation(tx, job, outcome.operation, outcome.error);
+ await audit(tx, channelId, 'writer_released', job.id, { status });
+ });
+
+ /**
+ * The run failed. Revokes its publication and fails its job unless it was already being
+ * stopped. `notSubmitted` marks a trusted pre-dispatch failure: nothing ran, so the writer
+ * is released in the same transaction. A late failure after the reply was published or the
+ * release settled the job changes nothing.
+ */
+ fail = async (
+ channelId: string,
+ jobId: string,
+ failure: { message: string; notSubmitted?: boolean },
+ ) =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId, true);
+ if (job.publishedMessageId || (!job.writerHeld && job.status !== 'running')) return;
+ if ((await operationStatus(tx, job)) === 'done') return;
+
+ const stopping = job.status === 'cancelled';
+ await tx
+ .update(channelJobs)
+ .set({
+ publicationRevoked: true,
+ ...(!stopping && isOpenJob(job) && { status: 'failed' as const }),
+ ...(failure.notSubmitted && {
+ leaseExpiresAt: null,
+ leaseOwner: null,
+ writerHeld: false,
+ }),
+ })
+ .where(eq(channelJobs.id, job.id));
+ await advanceOperation(
+ tx,
+ job,
+ stopping ? 'interrupted' : 'error',
+ stopping ? undefined : failure.message,
+ );
+ await audit(tx, channelId, 'execution_failed', job.id, {
+ message: failure.message,
+ notSubmitted: Boolean(failure.notSubmitted),
+ });
+ });
+
+ /**
+ * Lost the acknowledgement: the runtime may or may not have the input. The verdict is kept on
+ * the job, independent of whatever the runtime later records on the operation: publication
+ * is revoked and an open job fails, never redelivered. The writer stays held until
+ * termination is confirmed or it is isolated.
+ */
+ executionUnknown = async (channelId: string, jobId: string, message: string) =>
+ withChannelLock(this.db, channelId, async (tx) => {
+ const job = await claimed(tx, channelId, jobId, true);
+ if (!job.writerHeld || job.publishedMessageId || job.status === 'failed') return;
+
+ await tx
+ .update(channelJobs)
+ .set({
+ publicationRevoked: true,
+ ...(isOpenJob(job) && { status: 'failed' as const }),
+ })
+ .where(eq(channelJobs.id, job.id));
+ await advanceOperation(tx, job, 'abandoned', message);
+ await audit(tx, channelId, 'execution_unknown', job.id, { message });
+ });
+
+ /** Isolates a writer whose termination stayed unconfirmed. See {@link isolateWriter}. */
+ isolate = async (channelId: string, jobId: string, reason: string) =>
+ withChannelLock(this.db, channelId, async (tx) =>
+ isolateWriter(tx, await claimed(tx, channelId, jobId, true), reason),
+ );
+
+ /** System-initiated stop, e.g. a budget or reconcile decision. See {@link stopScope}. */
+ stop = async (channelId: string, scope: ChannelStopScope) =>
+ withChannelLock(this.db, channelId, (tx) => stopScope(tx, channelId, scope));
+
+ /**
+ * Extends the lease of a live run. Touches only the job row and takes no channel lock, so
+ * it cannot deadlock with channel writes. Returns false once the run lost its lease or
+ * writer.
+ */
+ heartbeat = async (
+ jobId: string,
+ lease: { leaseMs: number; leaseOwner: string },
+ ): Promise<boolean> => {
+ const now = new Date();
+ const renewed = await this.db
+ .update(channelJobs)
+ .set({ leaseExpiresAt: new Date(now.getTime() + lease.leaseMs) })
+ .where(
+ and(
+ eq(channelJobs.id, jobId),
+ eq(channelJobs.leaseOwner, lease.leaseOwner),
+ eq(channelJobs.writerHeld, true),
+ gt(channelJobs.leaseExpiresAt, now),
+ ),
+ )
+ .returning({ id: channelJobs.id });
+
+ return renewed.length > 0;
+ };
+}
diff --git a/packages/database/src/repositories/channel/index.ts b/packages/database/src/repositories/channel/index.ts
new file mode 100644
index 00000000000..416640362d9
--- /dev/null
+++ b/packages/database/src/repositories/channel/index.ts
@@ -0,0 +1,229 @@
+import type { ChannelMemberRole, ChannelVisibility } from '@lobechat/types';
+import { and, desc, eq, isNull, or } from 'drizzle-orm';
+
+import type { ChannelItem, ChannelJobItem, ChannelMessageItem } from '../../schemas';
+import { channelJobs, channelMembers, channelMessages, channels } from '../../schemas';
+import type { LobeChatDatabase, Transaction } from '../../type';
+import { normalizeWorkspaceId } from '../../utils/workspace';
+import type { ChannelAddAgentInput } from './agent';
+import { addAgentMember, requireChannelAgent } from './agent';
+import { ChannelError } from './error';
+import { retryRouting } from './routing';
+import type { ChannelSendInput } from './send';
+import { sendMessage } from './send';
+import type { ChannelStopScope } from './stop';
+import { stopScope } from './stop';
+import { lockChannel } from './transaction';
+import type { ChannelAccess, ChannelWriteOptions } from './types';
+
+export type { ChannelAddAgentInput } from './agent';
+export type { ChannelClaim, ChannelClaimOptions } from './claim';
+export type { ChannelErrorCode } from './error';
+export { ChannelError } from './error';
+export { ChannelExecutionRepository } from './execution';
+export type { ChannelRoutingDecision } from './routing';
+export type { ChannelSendInput } from './send';
+export type { ChannelStopScope } from './stop';
+export type { ChannelAccess, ChannelWriteOptions } from './types';
+
+const ROLE_RANK: Record<ChannelMemberRole, number> = { admin: 1, member: 0, owner: 2 };
+
+const hasRole = (role: ChannelMemberRole | null, minRole: ChannelMemberRole) =>
+ ROLE_RANK[role ?? 'member'] >= ROLE_RANK[minRole];
+
+/**
+ * Membership-scoped access to channels (LOBE-15104 §4).
+ *
+ * A caller reaches a channel only through its own active human member row, in the current
+ * scope (personal, or the given workspace). Every write runs inside `write`, which holds the
+ * `channels` row lock so mutations of one channel serialize in a transaction.
+ */
+export class ChannelRepository {
+ private readonly workspaceId: string | null;
+
+ constructor(
+ private readonly db: LobeChatDatabase,
+ private readonly userId: string,
+ workspaceId?: string | null,
+ ) {
+ this.workspaceId = normalizeWorkspaceId(workspaceId);
+ }
+
+ /**
+ * Creates the channel with the caller as its owner member. With `agentId`, opens the caller's
+ * direct conversation with that Agent in this scope, returning the existing one if present.
+ */
+ create = async (params: { agentId?: string; title: string; visibility?: ChannelVisibility }) =>
+ this.db.transaction(async (tx) => {
+ const { agentId } = params;
+ if (agentId !== undefined && (!agentId.trim() || params.visibility === 'public'))
+ throw new ChannelError(
+ 'BAD_REQUEST',
+ 'A direct conversation requires an Agent and private visibility',
+ );
+ if (agentId) {
+ await requireChannelAgent(tx, this.workspaceId, this.userId, agentId);
+ const existing = await this.findDirect(tx, agentId);
+ if (existing) return existing;
+ }
+ const insert = tx.insert(channels).values({
+ agentId,
+ userId: this.userId,
+ title: params.title,
+ visibility: params.visibility,
+ workspaceId: this.workspaceId,
+ });
+ // A concurrent open of the same direct conversation wins the unique index; reuse its row.
+ const [channel] = agentId
+ ? await insert.onConflictDoNothing().returning()
+ : await insert.returning();
+ if (!channel) {
+ const existing = agentId ? await this.findDirect(tx, agentId) : undefined;
+ if (existing) return existing;
+ throw new ChannelError('CONFLICT', 'The direct conversation is unavailable');
+ }
+ const [member] = await tx
+ .insert(channelMembers)
+ .values({
+ actorType: 'user',
+ channelId: channel.id,
+ lastReadSequence: 0,
+ role: 'owner',
+ userId: this.userId,
+ })
+ .returning();
+
+ if (agentId) await addAgentMember(tx, channel, this.userId, { agentId });
+
+ return { channel, member } satisfies ChannelAccess;
+ });
+
+ /** Adds a usable Agent reference; a missing reference is allowed only for retained history. */
+ addAgent = async (channelId: string, input: ChannelAddAgentInput) =>
+ this.write(channelId, (tx, { channel }) => addAgentMember(tx, channel, this.userId, input), {
+ minRole: 'admin',
+ });
+
+ /** Active channels the caller belongs to in the current scope, newest first. */
+ list = async (): Promise<ChannelItem[]> => {
+ const rows = await this.db
+ .select({ channel: channels })
+ .from(channels)
+ .innerJoin(channelMembers, eq(channelMembers.channelId, channels.id))
+ .where(and(this.membershipWhere(), eq(channels.archived, false)))
+ .orderBy(desc(channels.createdAt));
+
+ return rows.map((row) => row.channel);
+ };
+
+ /** Read access. Returns undefined when the channel is missing or the caller is no member. */
+ findAccess = async (channelId: string): Promise<ChannelAccess | undefined> => {
+ const [row] = await this.db
+ .select({ channel: channels, member: channelMembers })
+ .from(channels)
+ .innerJoin(channelMembers, eq(channelMembers.channelId, channels.id))
+ .where(and(eq(channels.id, channelId), this.membershipWhere()))
+ .limit(1);
+
+ return row;
+ };
+
+ /**
+ * Runs `fn` while holding the channel row lock, after checking that the caller is an
+ * active member with at least `minRole` (default `member`).
+ */
+ write = async <T>(
+ channelId: string,
+ fn: (tx: Transaction, access: ChannelAccess) => Promise<T>,
+ options: ChannelWriteOptions = {},
+ ): Promise<T> =>
+ this.db.transaction(async (tx) => {
+ await lockChannel(tx, channelId);
+
+ // Read membership only after the lock: a removal or demotion committed by the previous
+ // lock holder must be visible here, not the snapshot from before the wait.
+ const [access] = await tx
+ .select({ channel: channels, member: channelMembers })
+ .from(channels)
+ .innerJoin(channelMembers, eq(channelMembers.channelId, channels.id))
+ .where(and(eq(channels.id, channelId), this.membershipWhere()))
+ .limit(1);
+ if (!access) throw new ChannelError('NOT_FOUND', 'Channel not found');
+
+ const minRole = options.minRole ?? 'member';
+ if (!hasRole(access.member.role, minRole))
+ throw new ChannelError('FORBIDDEN', `Requires the ${minRole} role in this channel`);
+ if (access.channel.archived && !options.allowArchived)
+ throw new ChannelError('CONFLICT', 'Channel is archived');
+
+ return fn(tx, access);
+ });
+
+ /** Posts a message as the caller. See {@link sendMessage} for routing. */
+ send = async (channelId: string, input: ChannelSendInput): Promise<ChannelMessageItem> =>
+ this.write(channelId, (tx, access) => sendMessage(tx, access, input));
+
+ /**
+ * Stops one job (its requester or an admin) or a whole branch (admins). Returns the jobs
+ * whose writer is still held; the caller must stop them physically.
+ */
+ stop = async (channelId: string, scope: ChannelStopScope): Promise<ChannelJobItem[]> =>
+ this.write(
+ channelId,
+ async (tx, { member }) => {
+ if ('jobId' in scope && !hasRole(member.role, 'admin')) {
+ const [job] = await tx
+ .select({ requesterMemberId: channelJobs.requesterMemberId })
+ .from(channelJobs)
+ .where(and(eq(channelJobs.channelId, channelId), eq(channelJobs.id, scope.jobId)));
+ if (job && job.requesterMemberId !== member.id)
+ throw new ChannelError('FORBIDDEN', 'Only the requester or an admin can stop this job');
+ }
+ return stopScope(tx, channelId, scope);
+ },
+ { allowArchived: true, minRole: 'threadId' in scope ? 'admin' : 'member' },
+ );
+
+ /** Sends an unassigned message back to Jev. Its author or an admin may retry. */
+ retryRouting = async (channelId: string, messageId: string): Promise<ChannelMessageItem> =>
+ this.write(channelId, async (tx, { member }) => {
+ if (!hasRole(member.role, 'admin')) {
+ const [message] = await tx
+ .select({ userId: channelMessages.userId })
+ .from(channelMessages)
+ .where(and(eq(channelMessages.channelId, channelId), eq(channelMessages.id, messageId)));
+ if (message && message.userId !== member.userId)
+ throw new ChannelError('FORBIDDEN', 'Only the author or an admin can retry routing');
+ }
+ return retryRouting(tx, channelId, messageId);
+ });
+
+ private findDirect = async (
+ tx: Transaction,
+ agentId: string,
+ ): Promise<ChannelAccess | undefined> => {
+ const [row] = await tx
+ .select({ channel: channels, member: channelMembers })
+ .from(channels)
+ .innerJoin(channelMembers, eq(channelMembers.channelId, channels.id))
+ .where(
+ and(
+ eq(channels.agentId, agentId),
+ eq(channels.userId, this.userId),
+ this.membershipWhere(),
+ ),
+ )
+ .limit(1);
+ return row;
+ };
+
+ private membershipWhere() {
+ return and(
+ eq(channelMembers.actorType, 'user'),
+ eq(channelMembers.userId, this.userId),
+ eq(channelMembers.active, true),
+ or(isNull(channels.agentId), eq(channels.userId, this.userId)),
+ this.workspaceId ? eq(channels.workspaceId, this.workspaceId) : isNull(channels.workspaceId),
+ );
+ }
+}
diff --git a/packages/database/src/repositories/channel/manifest.ts b/packages/database/src/repositories/channel/manifest.ts
new file mode 100644
index 00000000000..52ffab2da97
--- /dev/null
+++ b/packages/database/src/repositories/channel/manifest.ts
@@ -0,0 +1,132 @@
+import type { ChannelContextMessage, ChannelInputManifest } from '@lobechat/types';
+import {
+ agentDisplayName,
+ CHANNEL_DELETED_AGENT_NAME,
+ CHANNEL_DELETED_USER_NAME,
+} from '@lobechat/types';
+import { and, asc, eq, gt, isNull, lte, notExists, or } from 'drizzle-orm';
+
+import type {
+ ChannelJobItem,
+ ChannelMemberItem,
+ ChannelMessageItem,
+ ChannelThreadItem,
+} from '../../schemas';
+import { agents, channelJobs, channelMessages, users } from '../../schemas';
+import type { LobeChatDatabase, Transaction } from '../../type';
+import { fileIdsByMessage } from './attachments';
+
+/** Freeze the new public input window; a fresh topic receives the full branch. */
+export const buildManifest = (params: {
+ afterSequence: number;
+ job: ChannelJobItem;
+ member: ChannelMemberItem;
+ request: ChannelMessageItem;
+ thread: ChannelThreadItem | null;
+}): ChannelInputManifest => {
+ const { afterSequence, job, member, request, thread } = params;
+
+ return {
+ afterSequence,
+ // Jobs inherit the request's branch, so the request itself always sorts last.
+ cutoffSequence: request.sequence,
+ requestMessageId: request.id,
+ requesterMemberId: job.requesterMemberId,
+ self: { agentId: member.agentId!, memberId: member.id, name: member.name ?? 'Agent' },
+ threadId: job.threadId,
+ threadRootSequence: thread?.rootSequence ?? null,
+ };
+};
+
+/** The branch messages a manifest covers; see {@link buildManifest}. */
+const manifestScope = (channelId: string, manifest: ChannelInputManifest) => {
+ const { threadId, threadRootSequence } = manifest;
+ const mainPrefix =
+ threadRootSequence === null
+ ? undefined
+ : and(isNull(channelMessages.threadId), lte(channelMessages.sequence, threadRootSequence));
+
+ return and(
+ eq(channelMessages.channelId, channelId),
+ lte(channelMessages.sequence, manifest.cutoffSequence),
+ gt(channelMessages.sequence, manifest.afterSequence),
+ threadId
+ ? or(eq(channelMessages.threadId, threadId), mainPrefix)
+ : isNull(channelMessages.threadId),
+ );
+};
+
+/**
+ * The messages a manifest froze, oldest first. Needs no channel lock: Channel writes change
+ * only the routing fields of a sent message, and sequences only grow, so nothing at or before
+ * the cutoff changes. Author names and attachments are read at call time: a deleted account
+ * reads as deleted and a deleted file is no longer listed.
+ */
+export const readManifestMessages = async (
+ db: LobeChatDatabase | Transaction,
+ channelId: string,
+ manifest: ChannelInputManifest,
+ topicId: string | null,
+): Promise<ChannelContextMessage[]> => {
+ const scope = and(
+ manifestScope(channelId, manifest),
+ // A continued topic already contains its own answers. They may have been published
+ // after the next request was queued, so the input cursor alone cannot exclude them.
+ manifest.afterSequence > 0 && topicId
+ ? notExists(
+ db
+ .select({ id: channelJobs.id })
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.topicId, topicId),
+ eq(channelJobs.publishedMessageId, channelMessages.id),
+ ),
+ ),
+ )
+ : undefined,
+ );
+ const visible = await db
+ .select({
+ agentId: channelMessages.agentId,
+ agentName: agents.name,
+ agentTitle: agents.title,
+ fullName: users.fullName,
+ routingStatus: channelMessages.routingStatus,
+ userId: channelMessages.userId,
+ username: users.username,
+ content: channelMessages.content,
+ id: channelMessages.id,
+ sequence: channelMessages.sequence,
+ threadId: channelMessages.threadId,
+ })
+ .from(channelMessages)
+ .leftJoin(users, eq(users.id, channelMessages.userId))
+ .leftJoin(agents, eq(agents.id, channelMessages.agentId))
+ .where(scope)
+ .orderBy(asc(channelMessages.sequence));
+ const attachments = await fileIdsByMessage(
+ db,
+ db.select({ id: channelMessages.id }).from(channelMessages).where(scope),
+ );
+
+ return visible.map((message) => {
+ const isAgent = message.routingStatus === 'reply';
+ return {
+ author: {
+ id: isAgent ? message.agentId : message.userId,
+ name: isAgent
+ ? message.agentId
+ ? agentDisplayName({ name: message.agentName, title: message.agentTitle }, 'Agent')
+ : CHANNEL_DELETED_AGENT_NAME
+ : message.fullName || message.username || CHANNEL_DELETED_USER_NAME,
+ type: isAgent ? 'agent' : 'user',
+ },
+ content: message.content,
+ ...(attachments.has(message.id) && { fileIds: attachments.get(message.id) }),
+ id: message.id,
+ sequence: message.sequence,
+ threadId: message.threadId,
+ };
+ });
+};
diff --git a/packages/database/src/repositories/channel/routing.ts b/packages/database/src/repositories/channel/routing.ts
new file mode 100644
index 00000000000..70c608ca831
--- /dev/null
+++ b/packages/database/src/repositories/channel/routing.ts
@@ -0,0 +1,111 @@
+import type { ChannelMessageRoutingStatus } from '@lobechat/types';
+import { and, eq, sql } from 'drizzle-orm';
+
+import type { ChannelMessageItem } from '../../schemas';
+import { channelMembers, channelMessages } from '../../schemas';
+import type { Transaction } from '../../type';
+import { candidateAgents, deliver, findThread } from './delivery';
+import { ChannelError } from './error';
+import { audit } from './transaction';
+
+export type ChannelRoutingDecision =
+ | { memberIds: string[]; reason: string; status: 'assigned' }
+ | { reason: string; status: Extract<ChannelMessageRoutingStatus, 'skipped' | 'unassigned'> };
+
+const findMessage = async (tx: Transaction, channelId: string, messageId: string) => {
+ const [message] = await tx
+ .select()
+ .from(channelMessages)
+ .where(and(eq(channelMessages.channelId, channelId), eq(channelMessages.id, messageId)));
+ if (!message) throw new ChannelError('NOT_FOUND', 'Message not found');
+
+ return message;
+};
+
+/**
+ * Writes back a Jev decision. Applies only while the message is still `pending` at the same
+ * attempt, so a late answer can never overwrite a retry or a stop. Chosen members that are
+ * no longer candidates are dropped. Returns false when the result was stale.
+ */
+export const resolveRouting = async (
+ tx: Transaction,
+ channelId: string,
+ messageId: string,
+ attempt: number,
+ decision: ChannelRoutingDecision,
+): Promise<boolean> => {
+ const message = await findMessage(tx, channelId, messageId);
+ if (message.routingStatus !== 'pending' || message.routingAttempt !== attempt) return false;
+
+ const thread = await findThread(tx, channelId, message.threadId);
+ const chosen =
+ decision.status === 'assigned'
+ ? (await candidateAgents(tx, channelId, thread)).filter((agent) =>
+ decision.memberIds.includes(agent.id),
+ )
+ : [];
+ const [requester] = message.userId
+ ? await tx
+ .select({ id: channelMembers.id })
+ .from(channelMembers)
+ .where(
+ and(
+ eq(channelMembers.channelId, channelId),
+ eq(channelMembers.userId, message.userId),
+ eq(channelMembers.actorType, 'user'),
+ eq(channelMembers.active, true),
+ ),
+ )
+ : [];
+ const delivered = requester ? await deliver(tx, message, chosen, requester.id) : [];
+ const status =
+ decision.status === 'assigned' && !delivered.length ? 'unassigned' : decision.status;
+
+ await tx
+ .update(channelMessages)
+ .set({
+ recipientMemberIds: delivered,
+ routingReason:
+ delivered.length || decision.status !== 'assigned'
+ ? decision.reason
+ : requester
+ ? 'Chosen Agents are no longer available'
+ : 'The message sender is no longer available',
+ routingSource: 'jev',
+ routingStatus: status,
+ })
+ .where(eq(channelMessages.id, messageId));
+ await audit(tx, channelId, 'routing_decided', messageId, {
+ attempt,
+ reason: decision.reason,
+ recipients: delivered,
+ status,
+ });
+
+ return true;
+};
+
+/** Sends an `unassigned` message back to Jev under a new attempt number. */
+export const retryRouting = async (
+ tx: Transaction,
+ channelId: string,
+ messageId: string,
+): Promise<ChannelMessageItem> => {
+ const message = await findMessage(tx, channelId, messageId);
+ if (message.routingStatus !== 'unassigned')
+ throw new ChannelError('CONFLICT', 'Only an unassigned message can be routed again');
+
+ const [retried] = await tx
+ .update(channelMessages)
+ .set({
+ routingAttempt: sql`${channelMessages.routingAttempt} + 1`,
+ routingReason: null,
+ routingSource: null,
+ routingStatus: 'pending',
+ })
+ .where(eq(channelMessages.id, messageId))
+ .returning();
+ await audit(tx, channelId, 'routing_retried', messageId, { attempt: retried.routingAttempt });
+
+ return { ...retried, content: message.content };
+};
diff --git a/packages/database/src/repositories/channel/send.ts b/packages/database/src/repositories/channel/send.ts
new file mode 100644
index 00000000000..43096cf1c31
--- /dev/null
+++ b/packages/database/src/repositories/channel/send.ts
@@ -0,0 +1,169 @@
+import type { ChannelRoutingMode } from '@lobechat/types';
+import { CHANNEL_LIMITS } from '@lobechat/types';
+import { and, asc, eq, inArray } from 'drizzle-orm';
+
+import type { ChannelMessageItem } from '../../schemas';
+import { channelMessages, channelThreads, files } from '../../schemas';
+import type { Transaction } from '../../type';
+import { isUuid } from '../../utils/uuid';
+import { buildWorkspaceWhere } from '../../utils/workspace';
+import { attachFiles, fileIdsByMessage } from './attachments';
+import { activeMembers, appendMessage, candidateAgents, deliver, findThread } from './delivery';
+import { ChannelError } from './error';
+import { audit } from './transaction';
+import type { ChannelAccess } from './types';
+
+export interface ChannelSendInput {
+ content: string;
+ fileIds?: string[];
+ /** Member ids. Mentioned Agents run; mentioned people are only notified. */
+ mentions?: string[];
+ /** Client retry key; a retry with the same key returns the original message. */
+ requestKey: string;
+ /** How to route a message without @mentioned Agents. */
+ routing: ChannelRoutingMode;
+ threadId?: string | null;
+}
+
+const sameList = (a: string[], b: string[]) =>
+ a.length === b.length && a.every((value, index) => value === b[index]);
+
+export const validateSendInput = (input: ChannelSendInput) => {
+ const fileIds = [...new Set(input.fileIds ?? [])];
+ if (
+ (!input.content.trim() && !fileIds.length) ||
+ !input.requestKey ||
+ input.content.length > CHANNEL_LIMITS.contentLength ||
+ fileIds.length > CHANNEL_LIMITS.attachments
+ )
+ throw new ChannelError('BAD_REQUEST', 'A message requires bounded content and a retry key');
+
+ const mentions = input.mentions ?? [];
+ if (mentions.some((id) => !isUuid(id)))
+ throw new ChannelError('BAD_REQUEST', 'Mentions must be valid member UUIDs');
+
+ return { fileIds, mentions: [...new Set(mentions.map((id) => id.toLowerCase()))] };
+};
+
+/**
+ * Posts a human message. The caller holds the channel lock and is `access.member`.
+ *
+ * - @mentioned Agents get jobs in this transaction (`directed`, source `explicit`).
+ * - @mentioning only people wakes no Agent.
+ * - Without mentions, `jev` leaves the message `pending` for the routing task, and
+ * `fallback` hands it to every candidate Agent at once.
+ */
+export const sendMessage = async (
+ tx: Transaction,
+ { channel, member }: ChannelAccess,
+ input: ChannelSendInput,
+): Promise<ChannelMessageItem> => {
+ const { fileIds, mentions } = validateSendInput(input);
+ const threadId = input.threadId || null;
+
+ const [existing] = await tx
+ .select()
+ .from(channelMessages)
+ .where(
+ and(
+ eq(channelMessages.channelId, channel.id),
+ eq(channelMessages.requestKey, input.requestKey),
+ ),
+ );
+ if (existing) {
+ const existingFileIds = (await fileIdsByMessage(tx, [existing.id])).get(existing.id) ?? [];
+ if (
+ existing.userId !== member.userId ||
+ existing.agentId !== null ||
+ existing.content !== input.content ||
+ existing.threadId !== threadId ||
+ !sameList(existingFileIds, fileIds) ||
+ !sameList(existing.mentions, mentions)
+ )
+ throw new ChannelError('CONFLICT', 'Retry key was already used for a different message');
+ return existing;
+ }
+
+ const thread = await findThread(tx, channel.id, threadId);
+ if (fileIds.length) {
+ // Lock in a stable order so concurrent sends and file cleanup cannot deadlock.
+ const accessible = await tx
+ .select({ id: files.id })
+ .from(files)
+ .where(
+ and(
+ inArray(files.id, fileIds),
+ buildWorkspaceWhere(
+ { userId: member.userId!, workspaceId: channel.workspaceId ?? undefined },
+ files,
+ ),
+ ),
+ )
+ .orderBy(asc(files.id))
+ .for('update');
+ if (accessible.length !== fileIds.length)
+ throw new ChannelError('BAD_REQUEST', 'One or more attachments are unavailable');
+ }
+
+ const mentioned = await activeMembers(tx, channel.id, mentions);
+ const mentionedAgents = mentioned.filter((target) => target.actorType === 'agent');
+ if (thread && mentioned.length) {
+ await tx
+ .update(channelThreads)
+ .set({ followerMemberIds: [...new Set([...thread.followerMemberIds, ...mentions])] })
+ .where(eq(channelThreads.id, thread.id));
+ }
+
+ const candidates = mentions.length
+ ? []
+ : await candidateAgents(tx, channel.id, channel.agentId ? null : thread);
+ const direct = !!channel.agentId && candidates.length > 0;
+ const routed = mentions.length
+ ? ({ reason: 'Mentioned', source: 'explicit', status: 'directed' } as const)
+ : !candidates.length
+ ? ({ reason: 'No Agent can answer here', source: null, status: 'skipped' } as const)
+ : direct
+ ? ({ reason: 'Direct conversation', source: 'explicit', status: 'directed' } as const)
+ : input.routing === 'jev'
+ ? ({ reason: null, source: null, status: 'pending' } as const)
+ : ({
+ reason: 'No decision model configured',
+ source: 'fallback',
+ status: 'assigned',
+ } as const);
+ const recipients = mentions.length
+ ? mentionedAgents
+ : direct || routed.status === 'assigned'
+ ? candidates
+ : [];
+
+ const message = await appendMessage(tx, {
+ userId: member.userId,
+ channelId: channel.id,
+ content: input.content,
+ mentions,
+ requestKey: input.requestKey,
+ routingAttempt: routed.status === 'pending' ? 1 : 0,
+ routingReason: routed.reason,
+ routingSource: routed.source,
+ routingStatus: routed.status,
+ threadId,
+ });
+ await attachFiles(tx, { fileIds, messageId: message.id });
+ const delivered = await deliver(tx, message, recipients, member.id);
+ if (delivered.length) {
+ await tx
+ .update(channelMessages)
+ .set({ recipientMemberIds: delivered })
+ .where(eq(channelMessages.id, message.id));
+ message.recipientMemberIds = delivered;
+ }
+
+ await audit(tx, channel.id, 'message_accepted', message.id, {
+ mentions,
+ recipients: delivered,
+ routing: routed.status,
+ });
+
+ return message;
+};
diff --git a/packages/database/src/repositories/channel/stop.ts b/packages/database/src/repositories/channel/stop.ts
new file mode 100644
index 00000000000..0304fc31fc8
--- /dev/null
+++ b/packages/database/src/repositories/channel/stop.ts
@@ -0,0 +1,111 @@
+import { and, eq, inArray, isNull, sql } from 'drizzle-orm';
+
+import type { ChannelJobItem } from '../../schemas';
+import { channelJobs, channelMessages } from '../../schemas';
+import type { Transaction } from '../../type';
+import { findThread } from './delivery';
+import { audit } from './transaction';
+import { OPEN_JOB_STATUSES } from './writer';
+
+/** One job, or everything in a branch (`threadId: null` is the main channel). */
+export type ChannelStopScope = { jobId: string } | { threadId: string | null };
+
+/** What a stop decides on; a branch can hold many jobs, so their manifests are not loaded. */
+const stopColumns = {
+ claimed: sql<boolean>`${channelJobs.manifest} IS NOT NULL`,
+ id: channelJobs.id,
+ publicationRevoked: channelJobs.publicationRevoked,
+ publishedMessageId: channelJobs.publishedMessageId,
+ writerHeld: channelJobs.writerHeld,
+};
+interface StopCandidate {
+ claimed: boolean;
+ id: string;
+ publicationRevoked: boolean;
+ publishedMessageId: string | null;
+ writerHeld: boolean;
+}
+
+/**
+ * Cancels queued and running jobs in the scope and revokes the publication of every claimed
+ * job that has not both published and released its writer. Pending routing in a branch is
+ * closed and its attempt bumped, so a late Jev answer is ignored.
+ *
+ * Returns the jobs whose writer is still held: the caller must stop them physically, and
+ * only that confirmation releases them.
+ */
+export const stopScope = async (
+ tx: Transaction,
+ channelId: string,
+ scope: ChannelStopScope,
+): Promise<ChannelJobItem[]> => {
+ let jobs: StopCandidate[];
+
+ if ('jobId' in scope) {
+ jobs = await tx
+ .select(stopColumns)
+ .from(channelJobs)
+ .where(and(eq(channelJobs.channelId, channelId), eq(channelJobs.id, scope.jobId)));
+ } else {
+ await findThread(tx, channelId, scope.threadId);
+ const inBranch = scope.threadId
+ ? eq(channelMessages.threadId, scope.threadId)
+ : isNull(channelMessages.threadId);
+ await tx
+ .update(channelMessages)
+ .set({
+ routingAttempt: sql`${channelMessages.routingAttempt} + 1`,
+ routingReason: 'Stopped before routing finished',
+ routingStatus: 'unassigned',
+ })
+ .where(
+ and(
+ eq(channelMessages.channelId, channelId),
+ eq(channelMessages.routingStatus, 'pending'),
+ inBranch,
+ ),
+ );
+
+ jobs = await tx
+ .select(stopColumns)
+ .from(channelJobs)
+ .where(
+ and(
+ eq(channelJobs.channelId, channelId),
+ scope.threadId ? eq(channelJobs.threadId, scope.threadId) : isNull(channelJobs.threadId),
+ ),
+ );
+ }
+ if (!jobs.length) return [];
+
+ const jobIds = jobs.map((job) => job.id);
+ const cancelled = await tx
+ .update(channelJobs)
+ .set({ status: 'cancelled' })
+ .where(and(inArray(channelJobs.id, jobIds), inArray(channelJobs.status, OPEN_JOB_STATUSES)))
+ .returning({ id: channelJobs.id });
+
+ const revocable = jobs
+ .filter(
+ (job) =>
+ job.claimed && !job.publicationRevoked && (!job.publishedMessageId || job.writerHeld),
+ )
+ .map((job) => job.id);
+ if (revocable.length)
+ await tx
+ .update(channelJobs)
+ .set({ publicationRevoked: true })
+ .where(inArray(channelJobs.id, revocable));
+
+ if (cancelled.length || revocable.length)
+ await audit(tx, channelId, 'stop_requested', 'jobId' in scope ? scope.jobId : channelId, {
+ jobs: cancelled.map((job) => job.id),
+ revoked: revocable,
+ threadId: 'threadId' in scope ? scope.threadId : null,
+ });
+
+ return tx
+ .select()
+ .from(channelJobs)
+ .where(and(inArray(channelJobs.id, jobIds), eq(channelJobs.writerHeld, true)));
+};
diff --git a/packages/database/src/repositories/channel/topic.ts b/packages/database/src/repositories/channel/topic.ts
new file mode 100644
index 00000000000..c81c41f58e9
--- /dev/null
+++ b/packages/database/src/repositories/channel/topic.ts
@@ -0,0 +1,73 @@
+import type { ChannelExecutionConfig } from '@lobechat/types';
+import { and, desc, eq, isNotNull, isNull, ne } from 'drizzle-orm';
+import isEqual from 'fast-deep-equal';
+
+import type { ChannelItem, ChannelJobItem, ChannelMemberItem } from '../../schemas';
+import { agentOperations, channelJobs, topics } from '../../schemas';
+import type { Transaction } from '../../type';
+
+// Matches Bot AgentBridgeService: check on the next request, never expire guild Threads.
+const TOPIC_STALE_THRESHOLD = 4 * 60 * 60 * 1000;
+
+/** Resolve continuation from the source-side job history, without Channel fields on topics. */
+export const resolveTopic = async (
+ tx: Transaction,
+ channel: ChannelItem,
+ job: ChannelJobItem,
+ member: ChannelMemberItem,
+ userId: string,
+ requestSequence: number,
+ executionConfig: ChannelExecutionConfig,
+) => {
+ const [previous] = await tx
+ .select({ job: channelJobs, operation: agentOperations, topic: topics })
+ .from(channelJobs)
+ .leftJoin(topics, eq(topics.id, channelJobs.topicId))
+ .leftJoin(agentOperations, eq(agentOperations.id, channelJobs.operationId))
+ .where(
+ and(
+ eq(channelJobs.channelId, channel.id),
+ eq(channelJobs.memberId, member.id),
+ eq(channelJobs.requesterMemberId, job.requesterMemberId),
+ job.threadId ? eq(channelJobs.threadId, job.threadId) : isNull(channelJobs.threadId),
+ ne(channelJobs.id, job.id),
+ isNotNull(channelJobs.claimedAt),
+ ),
+ )
+ .orderBy(desc(channelJobs.claimedAt), desc(channelJobs.id))
+ .limit(1);
+
+ const prior = previous?.job;
+ const topic = previous?.topic;
+ if (
+ prior?.manifest &&
+ topic &&
+ prior.manifest.cutoffSequence < requestSequence &&
+ prior.acceptedAt &&
+ !prior.writerHeld &&
+ !prior.publicationRevoked &&
+ !prior.isolatedAt &&
+ prior.draft !== null &&
+ previous.operation?.status === 'done' &&
+ isEqual(prior.executionConfig, executionConfig) &&
+ topic.agentId === member.agentId &&
+ topic.userId === userId &&
+ topic.workspaceId === channel.workspaceId &&
+ !topic.isDeleted &&
+ (job.threadId || Date.now() - topic.updatedAt.getTime() <= TOPIC_STALE_THRESHOLD)
+ ) {
+ return { afterSequence: prior.manifest.cutoffSequence, topic };
+ }
+
+ const [created] = await tx
+ .insert(topics)
+ .values({
+ agentId: member.agentId,
+ mode: 'default',
+ trigger: 'channel',
+ userId,
+ workspaceId: channel.workspaceId,
+ })
+ .returning();
+ return { afterSequence: 0, topic: created };
+};
diff --git a/packages/database/src/repositories/channel/transaction.ts b/packages/database/src/repositories/channel/transaction.ts
new file mode 100644
index 00000000000..e16a396d628
--- /dev/null
+++ b/packages/database/src/repositories/channel/transaction.ts
@@ -0,0 +1,43 @@
+import type { ChannelAuditDetails } from '@lobechat/types';
+import { eq } from 'drizzle-orm';
+
+import type { ChannelItem } from '../../schemas';
+import { channelAudit, channels } from '../../schemas';
+import type { LobeChatDatabase, Transaction } from '../../type';
+import { ChannelError } from './error';
+
+/**
+ * Locks the channel row. Every channel write takes this lock before it touches any child
+ * row, so writers always lock in the same order. The returned row is the latest version.
+ */
+export const lockChannel = async (tx: Transaction, channelId: string): Promise<ChannelItem> => {
+ const [channel] = await tx
+ .select()
+ .from(channels)
+ .where(eq(channels.id, channelId))
+ .for('update');
+ if (!channel) throw new ChannelError('NOT_FOUND', 'Channel not found');
+
+ return channel;
+};
+
+/** Lock and run `fn` in one transaction. For system callers. */
+export const withChannelLock = async <T>(
+ db: LobeChatDatabase,
+ channelId: string,
+ fn: (tx: Transaction, channel: ChannelItem) => Promise<T>,
+): Promise<T> =>
+ db.transaction(async (tx) => {
+ const channel = await lockChannel(tx, channelId);
+ return fn(tx, channel);
+ });
+
+export const audit = async (
+ tx: Transaction,
+ channelId: string,
+ event: string,
+ targetId: string,
+ details: ChannelAuditDetails = {},
+) => {
+ await tx.insert(channelAudit).values({ channelId, details, event, targetId });
+};
diff --git a/packages/database/src/repositories/channel/types.ts b/packages/database/src/repositories/channel/types.ts
new file mode 100644
index 00000000000..18366c79daf
--- /dev/null
+++ b/packages/database/src/repositories/channel/types.ts
@@ -0,0 +1,15 @@
+import type { ChannelMemberRole } from '@lobechat/types';
+
+import type { ChannelItem, ChannelMemberItem } from '../../schemas';
+
+export interface ChannelAccess {
+ channel: ChannelItem;
+ /** The caller's own human member row. */
+ member: ChannelMemberItem;
+}
+
+export interface ChannelWriteOptions {
+ /** Lets owners and admins un-archive or clean up an archived channel. */
+ allowArchived?: boolean;
+ minRole?: ChannelMemberRole;
+}
diff --git a/packages/database/src/repositories/channel/writer.ts b/packages/database/src/repositories/channel/writer.ts
new file mode 100644
index 00000000000..6b3a5a9aeba
--- /dev/null
+++ b/packages/database/src/repositories/channel/writer.ts
@@ -0,0 +1,83 @@
+import type { AgentOperationStatus } from '@lobechat/types';
+import { and, eq, inArray } from 'drizzle-orm';
+
+import type { ChannelJobItem } from '../../schemas';
+import { agentOperations, channelJobs } from '../../schemas';
+import type { Transaction } from '../../type';
+import { audit } from './transaction';
+
+/** Operation statuses a channel transition may still advance. */
+export const LIVE_OPERATION_STATUSES: AgentOperationStatus[] = [
+ 'idle',
+ 'running',
+ 'waiting_for_async_tool',
+ 'waiting_for_client',
+ 'waiting_for_human',
+];
+
+/** Only in-flight operations can advance; runtime-owned metrics and trace remain untouched. */
+export const advanceOperation = async (
+ tx: Transaction,
+ job: ChannelJobItem,
+ status: AgentOperationStatus,
+ error?: string,
+) => {
+ if (!job.operationId) return;
+
+ await tx
+ .update(agentOperations)
+ .set({
+ status,
+ ...(status === 'running' ? { startedAt: new Date() } : { completedAt: new Date() }),
+ ...(error && { error: { message: error } }),
+ })
+ .where(
+ and(
+ eq(agentOperations.id, job.operationId),
+ inArray(agentOperations.status, LIVE_OPERATION_STATUSES),
+ ),
+ );
+};
+
+/** Current status of the job's operation, or undefined once the operation is gone. */
+export const operationStatus = async (
+ tx: Transaction,
+ job: ChannelJobItem,
+): Promise<AgentOperationStatus | undefined> => {
+ if (!job.operationId) return;
+
+ const [operation] = await tx
+ .select({ status: agentOperations.status })
+ .from(agentOperations)
+ .where(eq(agentOperations.id, job.operationId));
+ return operation?.status;
+};
+
+/** Job statuses a stop, failure or isolation still settles. */
+export const OPEN_JOB_STATUSES = ['queued', 'running'] as const;
+
+export const isOpenJob = (job: ChannelJobItem) =>
+ (OPEN_JOB_STATUSES as readonly string[]).includes(job.status);
+
+/**
+ * Logically isolates a writer whose termination stayed unconfirmed (INC-049). Its
+ * publication is revoked and an open job is settled as failed, so the member can run again.
+ * It never claims the process stopped: `writerHeld` stays set until physical confirmation,
+ * and the device directory stays locked until then.
+ */
+export const isolateWriter = async (tx: Transaction, job: ChannelJobItem, reason: string) => {
+ if (!job.writerHeld || job.isolatedAt) return false;
+
+ await tx
+ .update(channelJobs)
+ .set({
+ isolatedAt: new Date(),
+ publicationRevoked: true,
+ ...(isOpenJob(job) && { status: 'failed' as const }),
+ })
+ .where(eq(channelJobs.id, job.id));
+ await advanceOperation(tx, job, 'abandoned', reason);
+ await audit(tx, job.channelId, 'execution_isolated', job.id, { reason, status: job.status });
+
+ return true;
+};
diff --git a/packages/database/src/schemas/__tests__/channel.test.ts b/packages/database/src/schemas/__tests__/channel.test.ts
new file mode 100644
index 00000000000..a70695f3cb9
--- /dev/null
+++ b/packages/database/src/schemas/__tests__/channel.test.ts
@@ -0,0 +1,500 @@
+// @vitest-environment node
+import type { ChannelInputManifest, ChannelMemberConfig } from '@lobechat/types';
+import { eq, inArray } from 'drizzle-orm';
+import { afterEach, beforeEach, describe, expect, it } from 'vitest';
+
+import { getTestDB } from '../../core/getTestDB';
+import {
+ agentOperations,
+ agents,
+ channelJobs,
+ channelMemberGrants,
+ channelMembers,
+ channelMessageFiles,
+ channelMessages,
+ channels,
+ channelThreads,
+ files,
+ projects,
+ users,
+ workspaces,
+} from '..';
+
+const serverDB = await getTestDB();
+const ownerId = 'channel-schema-owner';
+const otherId = 'channel-schema-other';
+const workspaceId = 'channel-schema-workspace';
+
+const agentConfig: ChannelMemberConfig = {
+ deviceId: 'device-1',
+ deviceOwnerId: ownerId,
+ workingDirectory: '/repo',
+};
+
+const createChannel = async (title = 'Channel') => {
+ const [channel] = await serverDB
+ .insert(channels)
+ .values({ userId: ownerId, title, workspaceId })
+ .returning();
+ const [owner] = await serverDB
+ .insert(channelMembers)
+ .values({ actorType: 'user', channelId: channel.id, role: 'owner', userId: ownerId })
+ .returning();
+ const [source] = await serverDB
+ .insert(agents)
+ .values({ userId: ownerId, workspaceId })
+ .returning();
+ const [agent] = await serverDB
+ .insert(channelMembers)
+ .values({
+ actorType: 'agent',
+ agentId: source.id,
+ channelId: channel.id,
+ config: agentConfig,
+ name: 'Codex',
+ })
+ .returning();
+
+ return { agent, channel, owner };
+};
+
+const createMessage = async (channelId: string, authorMemberId: string, sequence: number) => {
+ const [sender] = await serverDB
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.id, authorMemberId));
+ const [message] = await serverDB
+ .insert(channelMessages)
+ .values({
+ agentId: sender.agentId,
+ userId: sender.userId,
+ channelId,
+ content: `message ${sequence}`,
+ requestKey: `request-${sequence}`,
+ routingStatus: sender.actorType === 'agent' ? 'reply' : 'directed',
+ sequence,
+ })
+ .returning();
+ return message;
+};
+
+const manifest = (requesterMemberId: string, memberId: string): ChannelInputManifest => ({
+ afterSequence: 0,
+ cutoffSequence: 1,
+ requestMessageId: 'unused',
+ requesterMemberId,
+ self: { agentId: 'fixture-agent', memberId, name: 'Codex' },
+ threadId: null,
+ threadRootSequence: null,
+});
+
+/** Creates a job claimed by `agent`, holding the writer on the given device directory. */
+const createClaimedJob = async (
+ fixture: Awaited<ReturnType<typeof createChannel>>,
+ sequence: number,
+ directory: { deviceId: string; workingDirectory: string } | null = {
+ deviceId: 'device-1',
+ workingDirectory: '/repo',
+ },
+) => {
+ const { agent, channel, owner } = fixture;
+ const message = await createMessage(channel.id, owner.id, sequence);
+ const [operation] = await serverDB
+ .insert(agentOperations)
+ .values({
+ id: `op_${channel.id}_${sequence}`,
+ userId: ownerId,
+ status: 'idle',
+ workspaceId,
+ })
+ .returning();
+
+ return serverDB
+ .insert(channelJobs)
+ .values({
+ channelId: channel.id,
+ manifest: manifest(owner.id, agent.id),
+ memberId: agent.id,
+ messageId: message.id,
+ operationId: operation.id,
+ requesterMemberId: owner.id,
+ status: 'running',
+ writerHeld: true,
+ ...directory,
+ })
+ .returning();
+};
+
+beforeEach(async () => {
+ await serverDB.insert(users).values([{ id: ownerId }, { id: otherId }]);
+ await serverDB
+ .insert(workspaces)
+ .values({ id: workspaceId, name: 'Workspace', primaryOwnerId: ownerId, slug: workspaceId });
+});
+
+afterEach(async () => {
+ await serverDB.delete(workspaces).where(eq(workspaces.id, workspaceId));
+ await serverDB.delete(users).where(inArray(users.id, [ownerId, otherId]));
+});
+
+describe('channel schema', () => {
+ it('generates UUIDs for internal messages and jobs', async () => {
+ const fixture = await createChannel();
+ const [job] = await createClaimedJob(fixture, 1);
+ expect(job.id).toMatch(/^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i);
+ expect(job.messageId).toMatch(
+ /^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,
+ );
+ });
+
+ it('defaults metadata to an empty object on every extensible channel table', async () => {
+ const { agent, channel, owner } = await createChannel();
+ const message = await createMessage(channel.id, owner.id, 1);
+ const [thread] = await serverDB
+ .insert(channelThreads)
+ .values({ channelId: channel.id, rootMessageId: message.id, rootSequence: 1 })
+ .returning();
+ const [grant] = await serverDB
+ .insert(channelMemberGrants)
+ .values({
+ channelId: channel.id,
+ deviceId: 'device-1',
+ deviceOwnerId: otherId,
+ memberId: agent.id,
+ requestedByMemberId: owner.id,
+ workingDirectory: '/repo',
+ })
+ .returning();
+
+ for (const row of [channel, owner, agent, grant, thread, message]) {
+ expect(row.metadata).toEqual({});
+ }
+ });
+
+ describe('members', () => {
+ it('enforces Agent references and preserves authored history after Agent deletion', async () => {
+ const { agent, channel, owner } = await createChannel();
+ const [source] = await serverDB.insert(agents).values({ userId: ownerId }).returning();
+
+ await expect(
+ serverDB
+ .update(channelMembers)
+ .set({ agentId: 'agt_missing' })
+ .where(eq(channelMembers.id, agent.id)),
+ ).rejects.toThrow();
+ await expect(
+ serverDB
+ .update(channelMembers)
+ .set({ agentId: source.id })
+ .where(eq(channelMembers.id, owner.id)),
+ ).rejects.toThrow();
+ await serverDB
+ .update(channelMembers)
+ .set({ agentId: source.id })
+ .where(eq(channelMembers.id, agent.id));
+ const message = await createMessage(channel.id, agent.id, 1);
+
+ await serverDB.delete(agents).where(eq(agents.id, source.id));
+
+ const [keptMember] = await serverDB
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.id, agent.id));
+ const [keptMessage] = await serverDB
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, message.id));
+ expect(keptMember).toMatchObject({ agentId: null, config: agentConfig, name: 'Codex' });
+ expect(keptMessage).toMatchObject({
+ agentId: null,
+ userId: null,
+ content: message.content,
+ routingStatus: 'reply',
+ });
+ });
+
+ it('keeps people and Agents in one member table with their own fields', async () => {
+ const { agent, owner } = await createChannel();
+
+ expect(owner).toMatchObject({ actorType: 'user', config: null, role: 'owner' });
+ expect(agent).toMatchObject({ actorType: 'agent', config: agentConfig, role: null });
+ expect(owner.metadata).toEqual({});
+ expect(agent.metadata).toEqual({});
+ });
+
+ it('rejects members whose fields do not match their actor type', async () => {
+ const { channel } = await createChannel();
+
+ await expect(
+ serverDB
+ .insert(channelMembers)
+ .values({ actorType: 'user', channelId: channel.id, userId: otherId }),
+ ).rejects.toThrow();
+ await expect(
+ serverDB
+ .insert(channelMembers)
+ .values({ actorType: 'agent', channelId: channel.id, name: 'No config' }),
+ ).rejects.toThrow();
+ await expect(
+ serverDB.insert(channelMembers).values({
+ actorType: 'agent',
+ channelId: channel.id,
+ config: agentConfig,
+ name: 'Agent with a person',
+ userId: otherId,
+ }),
+ ).rejects.toThrow();
+ });
+
+ it('rejects any field another actor type owns, and unknown actor types', async () => {
+ const { channel } = await createChannel();
+ const [source] = await serverDB.insert(agents).values({ userId: ownerId }).returning();
+ const expectCheckViolation = async (values: typeof channelMembers.$inferInsert) => {
+ const error = await serverDB
+ .insert(channelMembers)
+ .values(values)
+ .then(
+ () => undefined,
+ (caught: { cause?: { code?: string }; code?: string }) => caught,
+ );
+ expect(error?.cause?.code ?? error?.code).toBe('23514');
+ };
+ const person = { actorType: 'user', channelId: channel.id, role: 'member' } as const;
+ const agent = {
+ actorType: 'agent',
+ agentId: source.id,
+ channelId: channel.id,
+ config: agentConfig,
+ name: 'Agent',
+ } as const;
+
+ await expectCheckViolation({ ...person, agentId: source.id, userId: otherId });
+ await expectCheckViolation({ ...person, config: agentConfig, userId: otherId });
+ await expectCheckViolation({ ...agent, role: 'member' });
+ await expectCheckViolation({ ...agent, name: null });
+ await expectCheckViolation({
+ ...agent,
+ actorType: 'app' as typeof agent.actorType,
+ });
+ });
+
+ it('lets a person join a channel only once', async () => {
+ const { channel } = await createChannel();
+
+ await expect(
+ serverDB
+ .insert(channelMembers)
+ .values({ actorType: 'user', channelId: channel.id, role: 'member', userId: ownerId }),
+ ).rejects.toThrow();
+ });
+
+ it('keeps the authored history when a member deletes their account', async () => {
+ const { channel } = await createChannel();
+ const [other] = await serverDB
+ .insert(channelMembers)
+ .values({ actorType: 'user', channelId: channel.id, role: 'member', userId: otherId })
+ .returning();
+ const message = await createMessage(channel.id, other.id, 1);
+
+ await serverDB.delete(users).where(eq(users.id, otherId));
+
+ const [member] = await serverDB
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.id, other.id));
+ const [kept] = await serverDB
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, message.id));
+ expect(member.userId).toBeNull();
+ expect(kept).toMatchObject({ agentId: null, userId: null, content: message.content });
+ });
+ });
+
+ describe('messages', () => {
+ it('rejects a retried request key and invalid sender references', async () => {
+ const first = await createChannel('First');
+ const message = await createMessage(first.channel.id, first.owner.id, 1);
+
+ await expect(createMessage(first.channel.id, first.owner.id, 1)).rejects.toThrow();
+ for (const sender of [
+ { userId: 'missing-user' },
+ { userId: null, agentId: 'missing-agent', routingStatus: 'reply' as const },
+ { userId: ownerId, agentId: first.agent.agentId },
+ { userId: null, agentId: first.agent.agentId },
+ { userId: ownerId, routingStatus: 'reply' as const },
+ ]) {
+ await expect(
+ serverDB.insert(channelMessages).values({
+ ...message,
+ ...sender,
+ id: undefined,
+ sequence: 2,
+ requestKey: 'next',
+ }),
+ ).rejects.toThrow();
+ }
+ });
+
+ it('keeps Channel attachments unique and drops them with the file', async () => {
+ const first = await createChannel('First');
+ const message = await createMessage(first.channel.id, first.owner.id, 1);
+ const [file] = await serverDB
+ .insert(files)
+ .values({ fileType: 'text/plain', name: 'a.txt', size: 1, url: 'a.txt', userId: ownerId })
+ .returning();
+ const attach = () =>
+ serverDB
+ .insert(channelMessageFiles)
+ .values({ fileId: file.id, messageId: message.id, sortOrder: 0 });
+
+ await attach();
+ await expect(attach()).rejects.toThrow();
+
+ await serverDB.delete(files).where(eq(files.id, file.id));
+
+ const remaining = await serverDB
+ .select()
+ .from(channelMessageFiles)
+ .where(eq(channelMessageFiles.messageId, message.id));
+ expect(remaining).toHaveLength(0);
+ const [kept] = await serverDB
+ .select()
+ .from(channelMessages)
+ .where(eq(channelMessages.id, message.id));
+ expect(kept).toBeDefined();
+ });
+ });
+
+ describe('writer locks', () => {
+ it('allows one writer per member until it is released or isolated', async () => {
+ const fixture = await createChannel();
+ const [job] = await createClaimedJob(fixture, 1, null);
+
+ await expect(createClaimedJob(fixture, 2, null)).rejects.toThrow();
+
+ await serverDB
+ .update(channelJobs)
+ .set({ isolatedAt: new Date() })
+ .where(eq(channelJobs.id, job.id));
+ await expect(createClaimedJob(fixture, 3, null)).resolves.toHaveLength(1);
+ });
+
+ it('serializes writers on one device directory across channels', async () => {
+ const first = await createChannel('First');
+ const second = await createChannel('Second');
+ const [job] = await createClaimedJob(first, 1);
+
+ await expect(createClaimedJob(second, 1)).rejects.toThrow();
+ await expect(
+ createClaimedJob(second, 2, { deviceId: 'device-1', workingDirectory: '/other' }),
+ ).resolves.toHaveLength(1);
+
+ await serverDB
+ .update(channelJobs)
+ .set({ writerHeld: false })
+ .where(eq(channelJobs.id, job.id));
+ const third = await createChannel('Third');
+ await expect(createClaimedJob(third, 1)).resolves.toHaveLength(1);
+ });
+
+ it('keeps the directory locked while an isolated writer is still unconfirmed', async () => {
+ const first = await createChannel('First');
+ const second = await createChannel('Second');
+ const [job] = await createClaimedJob(first, 1);
+
+ await serverDB
+ .update(channelJobs)
+ .set({ isolatedAt: new Date() })
+ .where(eq(channelJobs.id, job.id));
+ await expect(createClaimedJob(second, 1)).rejects.toThrow();
+
+ await serverDB
+ .update(channelJobs)
+ .set({ writerHeld: false })
+ .where(eq(channelJobs.id, job.id));
+ await expect(createClaimedJob(second, 2)).resolves.toHaveLength(1);
+ });
+ });
+
+ describe('grants', () => {
+ it('binds one grant to each member', async () => {
+ const { agent, channel, owner } = await createChannel();
+ const grant = {
+ channelId: channel.id,
+ deviceId: 'device-1',
+ deviceOwnerId: otherId,
+ memberId: agent.id,
+ requestedByMemberId: owner.id,
+ workingDirectory: '/repo',
+ };
+
+ const [created] = await serverDB.insert(channelMemberGrants).values(grant).returning();
+ expect(created.id).toMatch(
+ /^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/i,
+ );
+ expect(created.status).toBe('pending');
+ await expect(serverDB.insert(channelMemberGrants).values(grant)).rejects.toThrow();
+ await expect(
+ serverDB.insert(channelMemberGrants).values({ ...grant, workingDirectory: '/other' }),
+ ).rejects.toThrow();
+ });
+ });
+
+ describe('channels', () => {
+ it('validates project associations and preserves history when the project is deleted', async () => {
+ const { channel, owner } = await createChannel();
+ expect(channel.projectId).toBeNull();
+ const message = await createMessage(channel.id, owner.id, 1);
+ await expect(
+ serverDB
+ .update(channels)
+ .set({ projectId: 'prj_missing' })
+ .where(eq(channels.id, channel.id)),
+ ).rejects.toThrow();
+
+ const [project] = await serverDB
+ .insert(projects)
+ .values({ name: 'Channel project', userId: ownerId, workspaceId })
+ .returning();
+ const [linked] = await serverDB
+ .update(channels)
+ .set({ projectId: project.id })
+ .where(eq(channels.id, channel.id))
+ .returning();
+ expect(linked.projectId).toBe(project.id);
+
+ await serverDB.delete(projects).where(eq(projects.id, project.id));
+
+ const [kept] = await serverDB.select().from(channels).where(eq(channels.id, channel.id));
+ expect(kept).toMatchObject({ id: channel.id, projectId: null, userId: ownerId, workspaceId });
+ expect(
+ await serverDB.select().from(channelMessages).where(eq(channelMessages.id, message.id)),
+ ).toHaveLength(1);
+ });
+
+ it('deletes a channel with all of its rows but keeps its operations', async () => {
+ const fixture = await createChannel();
+ const [job] = await createClaimedJob(fixture, 1);
+
+ await serverDB.delete(channels).where(eq(channels.id, fixture.channel.id));
+
+ const members = await serverDB
+ .select()
+ .from(channelMembers)
+ .where(eq(channelMembers.channelId, fixture.channel.id));
+ const jobs = await serverDB
+ .select()
+ .from(channelJobs)
+ .where(eq(channelJobs.channelId, fixture.channel.id));
+ expect(members).toHaveLength(0);
+ expect(jobs).toHaveLength(0);
+ // Ordinary execution history outlives its Channel source.
+ const [operation] = await serverDB
+ .select()
+ .from(agentOperations)
+ .where(eq(agentOperations.id, job.operationId!));
+ expect(operation).toMatchObject({ id: job.operationId, userId: ownerId });
+ });
+ });
+});
diff --git a/packages/database/src/schemas/channel.ts b/packages/database/src/schemas/channel.ts
new file mode 100644
index 00000000000..d7d1c8d310b
--- /dev/null
+++ b/packages/database/src/schemas/channel.ts
@@ -0,0 +1,500 @@
+import type {
+ ChannelAuditDetails,
+ ChannelExecutionConfig,
+ ChannelInputManifest,
+ ChannelJobBlockCode,
+ ChannelJobStatus,
+ ChannelMemberActorType,
+ ChannelMemberConfig,
+ ChannelMemberGrantMetadata,
+ ChannelMemberGrantRevokeReason,
+ ChannelMemberGrantStatus,
+ ChannelMemberMetadata,
+ ChannelMemberRole,
+ ChannelMessageMetadata,
+ ChannelMessageRoutingSource,
+ ChannelMessageRoutingStatus,
+ ChannelMetadata,
+ ChannelThreadMetadata,
+ ChannelVisibility,
+} from '@lobechat/types';
+import { sql } from 'drizzle-orm';
+import type { AnyPgColumn, PgTableExtraConfigValue } from 'drizzle-orm/pg-core';
+import {
+ boolean,
+ check,
+ foreignKey,
+ index,
+ integer,
+ jsonb,
+ pgTable,
+ text,
+ unique,
+ uniqueIndex,
+ uuid,
+ varchar,
+} from 'drizzle-orm/pg-core';
+
+import { idGenerator } from '../utils/idGenerator';
+import { createdAt, timestamptz, updatedAt } from './_helpers';
+import { agents } from './agent';
+import { agentOperations } from './agentOperations';
+import { files } from './file';
+import { projects } from './project';
+import { topics } from './topic';
+import { users } from './user';
+import { workspaces } from './workspace';
+
+/**
+ * Channel (LOBE-15104 §4): people and Agents in one shared conversation.
+ *
+ * Access is by membership, not by creator: a user reaches a channel only through an active
+ * `channel_members` row. Every write first locks the `channels` row, then touches child rows,
+ * so writers always take locks in the same order.
+ *
+ * Child tables expose `unique (channel_id, id)` so composite foreign keys keep every
+ * reference inside its own channel.
+ */
+export const channels = pgTable(
+ 'channels',
+ {
+ id: text('id')
+ .primaryKey()
+ .$defaultFn(() => idGenerator('channels'))
+ .notNull(),
+ /**
+ * Creator and personal-channel device/cleanup boundary; the human participant of a direct
+ * conversation. Channel access and role
+ * permissions are checked through membership.
+ * NULL once that account is deleted: a workspace channel outlives its creator, while
+ * personal channels are deleted explicitly with the account (`UserModel.deleteUser`).
+ */
+ userId: text('user_id').references(() => users.id, { onDelete: 'set null' }),
+ /** NULL for a personal channel. */
+ workspaceId: text('workspace_id').references(() => workspaces.id, { onDelete: 'cascade' }),
+ /** Optional project association; deleting the project preserves the channel. */
+ projectId: text('project_id').references(() => projects.id, { onDelete: 'set null' }),
+
+ /** Bound Agent for a direct conversation; NULL for a group. Deleted with the Agent. */
+ agentId: text('agent_id').references(() => agents.id, { onDelete: 'cascade' }),
+
+ title: text('title').notNull(),
+ /** Last allocated message sequence; incremented under the row lock when a message lands. */
+ sequence: integer('sequence').notNull().default(0),
+ archived: boolean('archived').notNull().default(false),
+
+ /**
+ * `public`: any workspace member can find and join. `private`: members only.
+ * Ignored for personal channels.
+ */
+ visibility: text('visibility').$type<ChannelVisibility>().notNull().default('private'),
+ metadata: jsonb('metadata').$type<ChannelMetadata>().default({}),
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ index('channels_user_id_idx').on(t.userId),
+ // One direct conversation per person, Agent and scope. The scope is part of the key because
+ // an Agent can be transferred to another workspace; leading `agent_id` serves the cascade.
+ uniqueIndex('channels_direct_unique')
+ .on(t.agentId, t.userId, sql`coalesce(${t.workspaceId}, '')`)
+ .where(sql`${t.agentId} IS NOT NULL`),
+ check(
+ 'channels_direct_visibility_check',
+ sql`${t.agentId} IS NULL OR ${t.visibility} = 'private'`,
+ ),
+ index('channels_project_id_idx')
+ .on(t.projectId)
+ .where(sql`${t.projectId} IS NOT NULL`),
+ index('channels_workspace_visibility_idx').on(t.workspaceId, t.visibility),
+ ],
+);
+
+/**
+ * People and Agents in a channel. Mentions, job participants, Thread followers and read
+ * positions all reference this one member identity.
+ */
+export const channelMembers = pgTable(
+ 'channel_members',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ actorType: text('actor_type').$type<ChannelMemberActorType>().notNull(),
+
+ // Human members
+ /**
+ * NULL once the account is deleted: retain the member for job and Thread references.
+ */
+ userId: text('user_id').references(() => users.id, { onDelete: 'set null' }),
+ role: text('role').$type<ChannelMemberRole>(),
+ /** Highest sequence this person has read in the main channel. */
+ lastReadSequence: integer('last_read_sequence'),
+
+ // Agent members
+ /** NULL after Agent deletion; keep membership and authored history. */
+ agentId: text('agent_id').references(() => agents.id, { onDelete: 'set null' }),
+ /** Channel routing/execution label; not an Agent configuration copy. */
+ name: text('name'),
+ description: text('description').notNull().default(''),
+ /** Channel-specific device/directory environment only. */
+ config: jsonb('config').$type<ChannelMemberConfig>(),
+ metadata: jsonb('metadata').$type<ChannelMemberMetadata>().default({}),
+
+ /** False once the member leaves; retain job and Thread references. */
+ active: boolean('active').notNull().default(true),
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ unique('channel_members_scope_unique').on(t.channelId, t.id),
+ uniqueIndex('channel_members_channel_user_unique')
+ .on(t.channelId, t.userId)
+ .where(sql`${t.userId} IS NOT NULL`),
+ index('channel_members_user_id_idx').on(t.userId),
+ index('channel_members_agent_id_idx').on(t.agentId),
+ // One constraint per rule, so a new actor type adds constraints instead of rewriting these.
+ check('channel_members_actor_type_check', sql`${t.actorType} IN ('user', 'agent')`),
+ check(
+ 'channel_members_user_shape_check',
+ sql`${t.actorType} <> 'user' OR ${t.role} IS NOT NULL`,
+ ),
+ check(
+ 'channel_members_agent_shape_check',
+ sql`${t.actorType} <> 'agent' OR (${t.name} IS NOT NULL AND ${t.config} IS NOT NULL)`,
+ ),
+ // Membership lookups match on `user_id`, so only a person may carry one.
+ check(
+ 'channel_members_user_id_owner_check',
+ sql`${t.userId} IS NULL OR ${t.actorType} = 'user'`,
+ ),
+ check('channel_members_role_owner_check', sql`${t.role} IS NULL OR ${t.actorType} = 'user'`),
+ check(
+ 'channel_members_agent_id_owner_check',
+ sql`${t.agentId} IS NULL OR ${t.actorType} = 'agent'`,
+ ),
+ check(
+ 'channel_members_config_owner_check',
+ sql`${t.config} IS NULL OR ${t.actorType} <> 'user'`,
+ ),
+ ],
+);
+
+/**
+ * Approval to run an Agent member on someone's personal device (or a private shared one).
+ * Binds to one (member, device, directory, environment revision); a switch needs a new grant.
+ * An approved grant covers every current and future person in the channel.
+ */
+export const channelMemberGrants = pgTable(
+ 'channel_member_grants',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ memberId: uuid('member_id').notNull(),
+ /** Device owner who approves, rejects or revokes. */
+ deviceOwnerId: text('device_owner_id')
+ .references(() => users.id, { onDelete: 'cascade' })
+ .notNull(),
+ deviceId: varchar('device_id', { length: 64 }).notNull(),
+ /** Canonical path, so `/repo` and `/repo/` bind to the same grant. */
+ workingDirectory: text('working_directory').notNull(),
+ /** Person who pulled the member in or switched its environment. */
+ requestedByMemberId: uuid('requested_by_member_id').notNull(),
+
+ status: text('status').$type<ChannelMemberGrantStatus>().notNull().default('pending'),
+ decidedAt: timestamptz('decided_at'),
+ revokedAt: timestamptz('revoked_at'),
+ revokeReason: text('revoke_reason').$type<ChannelMemberGrantRevokeReason>(),
+ metadata: jsonb('metadata').$type<ChannelMemberGrantMetadata>().default({}),
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ uniqueIndex('channel_member_grants_member_unique').on(t.memberId),
+ index('channel_member_grants_owner_status_idx').on(t.deviceOwnerId, t.status),
+ foreignKey({
+ columns: [t.channelId, t.memberId],
+ foreignColumns: [channelMembers.channelId, channelMembers.id],
+ name: 'channel_member_grants_member_fk',
+ }),
+ foreignKey({
+ columns: [t.channelId, t.requestedByMemberId],
+ foreignColumns: [channelMembers.channelId, channelMembers.id],
+ name: 'channel_member_grants_requester_fk',
+ }),
+ ],
+);
+
+export const channelAudit = pgTable(
+ 'channel_audit',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ /** e.g. `routing_decided`, `run_claimed`, `writer_isolated`. */
+ event: text('event').notNull(),
+ targetId: text('target_id').notNull(),
+ details: jsonb('details').$type<ChannelAuditDetails>().notNull().default({}),
+ createdAt: createdAt(),
+ },
+ (t) => [
+ index('channel_audit_channel_event_idx').on(t.channelId, t.event, t.createdAt),
+ index('channel_audit_target_event_idx').on(t.targetId, t.event, t.createdAt),
+ ],
+);
+
+export const channelThreads = pgTable(
+ 'channel_threads',
+ {
+ id: text('id')
+ .primaryKey()
+ .$defaultFn(() => idGenerator('channelThreads'))
+ .notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ rootMessageId: uuid('root_message_id').notNull(),
+ rootSequence: integer('root_sequence').notNull(),
+ /** Member ids (people and Agents) following this Thread. */
+ followerMemberIds: jsonb('follower_member_ids').$type<string[]>().notNull().default([]),
+ metadata: jsonb('metadata').$type<ChannelThreadMetadata>().default({}),
+ createdAt: createdAt(),
+ },
+ // Threads and messages reference each other; the annotation breaks the type cycle.
+ (t): PgTableExtraConfigValue[] => [
+ unique('channel_threads_scope_unique').on(t.channelId, t.id),
+ uniqueIndex('channel_threads_root_unique').on(t.channelId, t.rootMessageId),
+ foreignKey({
+ columns: [t.channelId, t.rootMessageId],
+ foreignColumns: [channelMessages.channelId, channelMessages.id],
+ name: 'channel_threads_root_fk',
+ }),
+ ],
+);
+
+/** Public Channel timeline, independent of Agent conversation messages. */
+export const channelMessages = pgTable(
+ 'channel_messages',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ threadId: text('thread_id'),
+ sequence: integer('sequence').notNull(),
+ content: text('content').notNull(),
+ /** Actual human sender, not the owner/requester of an Agent reply. */
+ userId: text('user_id').references(() => users.id, { onDelete: 'set null' }),
+ /** Actual Agent sender. Author deletion retains group history and clears its reference. */
+ agentId: text('agent_id').references(() => agents.id, { onDelete: 'set null' }),
+ /** Mentioned member ids. Mentioned Agents run; mentioned people are only notified. */
+ mentions: jsonb('mentions').$type<string[]>().notNull().default([]),
+ /** Client retry key for a human message; run identity for a published reply. */
+ requestKey: text('request_key').notNull(),
+ replyToId: uuid('reply_to_id'),
+
+ routingStatus: text('routing_status').$type<ChannelMessageRoutingStatus>().notNull(),
+ /** Where the recipients came from. NULL until routing settles, and on replies. */
+ routingSource: text('routing_source').$type<ChannelMessageRoutingSource>(),
+ /** Human-readable explanation of why these recipients (or none) were chosen. */
+ routingReason: text('routing_reason'),
+ /**
+ * Incremented each time routing starts. A `decide()` result is written back only when its
+ * attempt still matches, so a late answer cannot overwrite a retry.
+ */
+ routingAttempt: integer('routing_attempt').notNull().default(0),
+ /** Agent member ids that actually received a job for this message. */
+ recipientMemberIds: jsonb('recipient_member_ids').$type<string[]>().notNull().default([]),
+ metadata: jsonb('metadata').$type<ChannelMessageMetadata>().default({}),
+
+ createdAt: createdAt(),
+ },
+ // Threads and messages reference each other; the annotation breaks the type cycle.
+ (t): PgTableExtraConfigValue[] => [
+ unique('channel_messages_scope_unique').on(t.channelId, t.id),
+ uniqueIndex('channel_messages_sequence_unique').on(t.channelId, t.sequence),
+ uniqueIndex('channel_messages_request_key_unique').on(t.channelId, t.requestKey),
+ index('channel_messages_thread_sequence_idx').on(t.channelId, t.threadId, t.sequence),
+ /** Latest request per branch, without scanning Agent replies. */
+ index('channel_messages_request_sequence_idx')
+ .on(t.channelId, t.threadId, t.sequence)
+ .where(sql`${t.routingStatus} <> 'reply'`),
+ index('channel_messages_routing_pending_idx')
+ .on(t.channelId, t.id)
+ .where(sql`${t.routingStatus} = 'pending'`),
+ foreignKey({
+ columns: [t.channelId, t.threadId],
+ foreignColumns: [channelThreads.channelId, channelThreads.id],
+ name: 'channel_messages_thread_fk',
+ }),
+ // Both may be NULL after author deletion. Writers require one live sender on creation.
+ check('channel_messages_sender_check', sql`${t.userId} IS NULL OR ${t.agentId} IS NULL`),
+ check(
+ 'channel_messages_user_sender_check',
+ sql`${t.routingStatus} <> 'reply' OR ${t.userId} IS NULL`,
+ ),
+ check(
+ 'channel_messages_agent_sender_check',
+ sql`${t.routingStatus} = 'reply' OR ${t.agentId} IS NULL`,
+ ),
+ ],
+);
+
+/** Public attachment links are independent of internal conversation messages. */
+export const channelMessageFiles = pgTable(
+ 'channel_message_files',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ messageId: uuid('message_id')
+ .references(() => channelMessages.id, { onDelete: 'cascade' })
+ .notNull(),
+ fileId: text('file_id')
+ .references(() => files.id, { onDelete: 'cascade' })
+ .notNull(),
+ sortOrder: integer('sort_order').notNull(),
+ },
+ (t) => [
+ unique('channel_message_files_message_file_unique').on(t.messageId, t.fileId),
+ index('channel_message_files_file_idx').on(t.fileId),
+ ],
+);
+
+/**
+ * One delivery of one message to one Agent member; each member drains its jobs FIFO.
+ *
+ * Claiming a job reserves one canonical `agent_operations` row in a normal Agent
+ * topic (continued when safe); execution status, errors, usage and traces live on the
+ * operation. The job keeps only what the operation cannot: the frozen input, the execution
+ * lease, the writer lock and publication of the final reply.
+ */
+export const channelJobs = pgTable(
+ 'channel_jobs',
+ {
+ id: uuid('id').defaultRandom().primaryKey().notNull(),
+ channelId: text('channel_id')
+ .references(() => channels.id, { onDelete: 'cascade' })
+ .notNull(),
+ memberId: uuid('member_id').notNull(),
+ messageId: uuid('message_id').notNull(),
+ threadId: text('thread_id'),
+ /** Member who triggered the request; its user is the execution identity. */
+ requesterMemberId: uuid('requester_member_id').notNull(),
+ /** Separates redeliveries of the same message to the same member, e.g. after a retry. */
+ deliveryKey: text('delivery_key').notNull().default('initial'),
+ /**
+ * Channel outcome of this delivery. It may settle while the writer is still held, e.g. a
+ * stop cancels the job before the process exits; the locks follow `writerHeld`.
+ */
+ status: text('status').$type<ChannelJobStatus>().notNull().default('queued'),
+ blockedReason: text('blocked_reason'),
+ /** Machine-readable cause for `blockedReason`; clients must not parse the text. */
+ blockedCode: text('blocked_code').$type<ChannelJobBlockCode>(),
+
+ // Execution, set when the job is claimed
+ /** Actual claim time under the Channel lock; delayed routing can invert request order. */
+ claimedAt: timestamptz('claimed_at'),
+ /** Source-side link to the ordinary Agent conversation. */
+ topicId: text('topic_id').references(() => topics.id, { onDelete: 'set null' }),
+ /** Canonical execution reserved at claim time; NULL while the job waits. */
+ operationId: text('operation_id')
+ .unique()
+ .references((): AnyPgColumn => agentOperations.id, { onDelete: 'set null' }),
+ /** Where the run's input ends, frozen at claim; later messages belong to the next job. */
+ manifest: jsonb('manifest').$type<ChannelInputManifest>(),
+ /** Effective Agent settings and Channel environment frozen at claim time. */
+ executionConfig: jsonb('execution_config').$type<ChannelExecutionConfig>(),
+ /** Device of a device-hosted run; with `workingDirectory` it forms the directory lock. */
+ deviceId: varchar('device_id', { length: 64 }),
+ /** Canonical working directory acknowledged by the device. */
+ workingDirectory: text('working_directory'),
+ /** When the runtime confirmed it took the input. An unknown delivery never gets one. */
+ acceptedAt: timestamptz('accepted_at'),
+ /** Process (or queue worker) currently driving the run. */
+ leaseOwner: text('lease_owner'),
+ leaseExpiresAt: timestamptz('lease_expires_at'),
+ /**
+ * Set when the job is claimed. Cleared only by physical stop confirmation (process tree
+ * ended, or the native operation finished) or a trusted failure before dispatch, when
+ * nothing ran. Leases, idleness, interrupts and operation completion do not clear it.
+ */
+ writerHeld: boolean('writer_held').notNull().default(false),
+ /**
+ * Set when termination could not be confirmed in time (INC-049). Publication is revoked so
+ * the member may run again, though not in the same device directory until the stop is
+ * confirmed: isolation frees the member lock but never `writerHeld`.
+ */
+ isolatedAt: timestamptz('isolated_at'),
+ /** Final answer saved by the run; immutable once set. */
+ draft: text('draft'),
+ /** A revoked job never publishes. Set by stops, failures and isolation. */
+ publicationRevoked: boolean('publication_revoked').notNull().default(false),
+ publishedMessageId: uuid('published_message_id'),
+
+ createdAt: createdAt(),
+ updatedAt: updatedAt(),
+ },
+ (t) => [
+ unique('channel_jobs_scope_unique').on(t.channelId, t.id),
+ uniqueIndex('channel_jobs_delivery_unique').on(t.messageId, t.memberId, t.deliveryKey),
+ index('channel_jobs_channel_status_idx').on(t.channelId, t.status),
+ index('channel_jobs_continuation_idx').on(
+ t.memberId,
+ t.requesterMemberId,
+ t.threadId,
+ t.claimedAt,
+ ),
+ index('channel_jobs_topic_idx').on(t.topicId, t.publishedMessageId),
+ index('channel_jobs_member_queue_idx').on(t.memberId, t.status, t.createdAt),
+ index('channel_jobs_lease_expires_idx')
+ .on(t.leaseExpiresAt)
+ .where(sql`${t.writerHeld} AND ${t.isolatedAt} IS NULL`),
+ /** At most one writer per member. */
+ uniqueIndex('channel_jobs_active_member_unique')
+ .on(t.memberId)
+ .where(sql`${t.writerHeld} AND ${t.isolatedAt} IS NULL`),
+ /**
+ * At most one writer per device directory, across all channels. Unlike the member lock,
+ * isolation does not release it: only physical stop confirmation proves the old process
+ * has left the directory.
+ */
+ uniqueIndex('channel_jobs_active_directory_unique')
+ .on(t.deviceId, t.workingDirectory)
+ .where(
+ sql`${t.deviceId} IS NOT NULL AND ${t.workingDirectory} IS NOT NULL AND ${t.writerHeld}`,
+ ),
+ foreignKey({
+ columns: [t.channelId, t.memberId],
+ foreignColumns: [channelMembers.channelId, channelMembers.id],
+ name: 'channel_jobs_member_fk',
+ }),
+ foreignKey({
+ columns: [t.channelId, t.requesterMemberId],
+ foreignColumns: [channelMembers.channelId, channelMembers.id],
+ name: 'channel_jobs_requester_fk',
+ }),
+ foreignKey({
+ columns: [t.channelId, t.messageId],
+ foreignColumns: [channelMessages.channelId, channelMessages.id],
+ name: 'channel_jobs_message_fk',
+ }),
+ foreignKey({
+ columns: [t.channelId, t.threadId],
+ foreignColumns: [channelThreads.channelId, channelThreads.id],
+ name: 'channel_jobs_thread_fk',
+ }),
+ ],
+);
+
+export type ChannelItem = typeof channels.$inferSelect;
+export type NewChannel = typeof channels.$inferInsert;
+export type ChannelMemberItem = typeof channelMembers.$inferSelect;
+export type NewChannelMember = typeof channelMembers.$inferInsert;
+export type ChannelMemberGrantItem = typeof channelMemberGrants.$inferSelect;
+export type ChannelThreadItem = typeof channelThreads.$inferSelect;
+export type ChannelMessageItem = typeof channelMessages.$inferSelect;
+export type NewChannelMessage = typeof channelMessages.$inferInsert;
+export type ChannelJobItem = typeof channelJobs.$inferSelect;
diff --git a/packages/database/src/schemas/index.ts b/packages/database/src/schemas/index.ts
index c942fb0255f..e5818bb0659 100644
--- a/packages/database/src/schemas/index.ts
+++ b/packages/database/src/schemas/index.ts
@@ -19,6 +19,7 @@ export * from './aiInfra';
export * from './apiKey';
export * from './asyncTask';
export * from './betterAuth';
+export * from './channel';
export * from './chatGroup';
export * from './connector';
export * from './dashboard';
diff --git a/packages/database/src/utils/agent-access.ts b/packages/database/src/utils/agent-access.ts
index 8413a8cc9aa..228e166e517 100644
--- a/packages/database/src/utils/agent-access.ts
+++ b/packages/database/src/utils/agent-access.ts
@@ -2,7 +2,7 @@ import { TRPCError } from '@trpc/server';
import { and, eq } from 'drizzle-orm';
import { agents } from '../schemas';
-import type { LobeChatDatabase } from '../type';
+import type { LobeChatDatabase, Transaction } from '../type';
import { buildWorkspaceWhere } from './workspace';
interface AgentAccessCtx {
@@ -10,6 +10,10 @@ interface AgentAccessCtx {
workspaceId?: string;
}
+/** The same use-time scope for validation and reads that also need current Agent settings. */
+export const agentUsableByWhere = (agentId: string, ctx: AgentAccessCtx) =>
+ and(eq(agents.id, agentId), buildWorkspaceWhere(ctx, agents));
+
/**
* Assert that `ctx.userId` in `ctx.workspaceId` is allowed to use the agent —
* i.e. it's a public agent in the same workspace OR owned by the caller.
@@ -24,24 +28,14 @@ interface AgentAccessCtx {
* surface in sync with `buildWorkspaceWhere` semantics.
*/
export async function assertAgentUsableBy(
- db: LobeChatDatabase,
+ db: LobeChatDatabase | Transaction,
agentId: string,
ctx: AgentAccessCtx,
): Promise<void> {
const rows = await db
.select({ id: agents.id })
.from(agents)
- .where(
- and(
- eq(agents.id, agentId),
- buildWorkspaceWhere(ctx, {
- isDeleted: agents.isDeleted,
- userId: agents.userId,
- workspaceId: agents.workspaceId,
- visibility: agents.visibility,
- }),
- ),
- )
+ .where(agentUsableByWhere(agentId, ctx))
.limit(1);
if (rows.length === 0) {
diff --git a/packages/database/src/utils/agentConfig.ts b/packages/database/src/utils/agentConfig.ts
new file mode 100644
index 00000000000..9eca83c9766
--- /dev/null
+++ b/packages/database/src/utils/agentConfig.ts
@@ -0,0 +1,22 @@
+import { DEFAULT_AGENT_CONFIG } from '@lobechat/const';
+import type { LobeAgentConfig } from '@lobechat/types';
+import { cleanObject, merge } from '@lobechat/utils';
+import type { PartialDeep } from 'type-fest';
+
+/** Shared by AgentService and execution snapshots: system → server → personal → Agent. */
+export const mergeAgentDefaultConfig = (
+ agent: Record<string, unknown>,
+ options: {
+ serverDefault?: PartialDeep<LobeAgentConfig>;
+ userDefault?: unknown;
+ workspaceId?: string | null;
+ },
+): LobeAgentConfig => {
+ const base = merge(DEFAULT_AGENT_CONFIG, options.serverDefault ?? {});
+ // Shared Agents must never inherit the requesting member's personal defaults.
+ const userConfig = options.workspaceId
+ ? {}
+ : ((options.userDefault as { config?: PartialDeep<LobeAgentConfig> } | undefined)?.config ??
+ {});
+ return merge(merge(base, userConfig), cleanObject(agent));
+};
diff --git a/packages/database/src/utils/idGenerator.test.ts b/packages/database/src/utils/idGenerator.test.ts
index c5f5e142690..df1a5457ea7 100644
--- a/packages/database/src/utils/idGenerator.test.ts
+++ b/packages/database/src/utils/idGenerator.test.ts
@@ -24,6 +24,9 @@ describe('idGenerator', () => {
const userId = idGenerator('user');
expect(userId).toMatch(/^user_[\dA-Za-z]{12}$/);
+
+ expect(idGenerator('channels')).toMatch(/^chn_[\dA-Za-z]{12}$/);
+ expect(idGenerator('channelThreads')).toMatch(/^cht_[\dA-Za-z]{12}$/);
});
it('should generate an ID with custom size', () => {
diff --git a/packages/database/src/utils/idGenerator.ts b/packages/database/src/utils/idGenerator.ts
index db71ca10b34..0243b0c482f 100644
--- a/packages/database/src/utils/idGenerator.ts
+++ b/packages/database/src/utils/idGenerator.ts
@@ -14,6 +14,8 @@ const prefixes = {
tasks: 'task',
agents: 'agt',
budget: 'bgt',
+ channelThreads: 'cht',
+ channels: 'chn',
chatGroups: 'cg',
documents: 'docs',
evalBenchmarks: 'evb',
diff --git a/packages/types/src/channel.ts b/packages/types/src/channel.ts
new file mode 100644
index 00000000000..349e26d36bc
--- /dev/null
+++ b/packages/types/src/channel.ts
@@ -0,0 +1,152 @@
+import type { LobeAgentConfig } from './agent';
+
+/**
+ * Channel: a shared conversation where people and Agents talk together (LOBE-15104).
+ *
+ * Public content lives in channel_messages. Channel jobs trigger ordinary Agent topics
+ * and operations; the internal transcript stays separate from the public timeline.
+ */
+
+export const CHANNEL_RUNTIMES = [
+ 'native',
+ 'codex',
+ 'amp',
+ 'grok-build',
+ 'claude-code',
+ 'pi',
+] as const;
+export type ChannelRuntime = (typeof CHANNEL_RUNTIMES)[number];
+
+export const isChannelRuntime = (runtime: string): runtime is ChannelRuntime =>
+ (CHANNEL_RUNTIMES as readonly string[]).includes(runtime);
+
+export const CHANNEL_LIMITS = {
+ /** Files attached to one message. */
+ attachments: 20,
+ /** Characters in one message. */
+ contentLength: 100_000,
+} as const;
+
+/** Display name for a person whose account was deleted; their member row stays. */
+export const CHANNEL_DELETED_USER_NAME = 'Deleted user';
+export const CHANNEL_DELETED_AGENT_NAME = 'Deleted agent';
+
+/** Discoverability inside a workspace. Ignored for personal channels (`workspace_id IS NULL`). */
+export type ChannelVisibility = 'private' | 'public';
+
+export type ChannelMemberActorType = 'agent' | 'user';
+
+/** Role of a human member. Agent members carry no role. */
+export type ChannelMemberRole = 'admin' | 'member' | 'owner';
+
+/** Channel-specific execution environment; Agent settings always come from the Agent. */
+export interface ChannelMemberConfig {
+ deviceId?: string;
+ /**
+ * User whose device runs this member. Device calls route by this id, never by the channel
+ * creator, so a workspace channel can use another member's device after its owner approves.
+ */
+ deviceOwnerId?: string;
+ /** Set only from a device's canonical-path acknowledgement before claiming work. */
+ workingDirectory?: string;
+}
+
+/** Free-form member state that does not need its own column. */
+export type ChannelMemberMetadata = Record<string, unknown>;
+
+/** Free-form channel state that does not need its own column. */
+export type ChannelMetadata = Record<string, unknown>;
+
+/** Free-form grant state that does not need its own column. */
+export type ChannelMemberGrantMetadata = Record<string, unknown>;
+
+/** Free-form Thread state that does not need its own column. */
+export type ChannelThreadMetadata = Record<string, unknown>;
+
+/** Free-form public message state that does not need its own column. */
+export type ChannelMessageMetadata = Record<string, unknown>;
+
+/** Effective Agent settings and Channel environment, frozen once when a job is claimed. */
+export interface ChannelExecutionConfig extends LobeAgentConfig, ChannelMemberConfig {
+ provider: string;
+ runtime: ChannelRuntime;
+}
+
+/**
+ * - `directed`: carried explicit @mentions; jobs were created in the send transaction.
+ * - `pending`: waiting for Jev to pick responders.
+ * - `assigned`: Jev (or the no-model fallback) picked at least one Agent.
+ * - `unassigned`: Jev was unsure or failed; no Agent was woken and the user may retry.
+ * - `skipped`: Jev decided nobody needs to reply. Not a failure.
+ * - `reply`: an Agent's published reply; replies never enter routing.
+ */
+export type ChannelMessageRoutingStatus =
+ 'assigned' | 'directed' | 'pending' | 'reply' | 'skipped' | 'unassigned';
+
+/**
+ * - `explicit`: recipients came from @mentions, Thread followers or a bound direct Agent.
+ * - `jev`: recipients came from a `decide()` call.
+ * - `fallback`: no decision model is configured, so every available Agent was picked.
+ */
+export type ChannelMessageRoutingSource = 'explicit' | 'fallback' | 'jev';
+
+/**
+ * How a human message without @mentions is routed: `jev` when a decision model is
+ * configured, otherwise `fallback` to every candidate Agent.
+ */
+export type ChannelRoutingMode = 'fallback' | 'jev';
+
+/**
+ * - `queued`: waiting at the member's FIFO.
+ * - `running`: claimed; its operation carries the execution status.
+ * - `completed`: the final reply was published.
+ * - `failed`: ended without a publishable reply, or its execution failed or became unknown.
+ * - `cancelled`: stopped, or it can never run (requester left, environment switched).
+ */
+export type ChannelJobStatus = 'cancelled' | 'completed' | 'failed' | 'queued' | 'running';
+
+/** Why a queued job cannot start yet. Typed so clients never infer it from error text. */
+export type ChannelJobBlockCode =
+ | 'device_approval_pending'
+ | 'device_offline'
+ | 'directory_locked'
+ | 'unavailable'
+ | 'workspace_changed';
+
+/** Approval of a member that executes on someone's personal device (or a private shared one). */
+export type ChannelMemberGrantStatus = 'approved' | 'pending' | 'rejected' | 'revoked';
+
+export type ChannelMemberGrantRevokeReason = 'device_owner_left' | 'revoked_by_owner';
+
+export interface ChannelContextMessage {
+ /** `id` is the actual user/Agent id, or NULL after author deletion. */
+ author: { id: string | null; name: string; type: ChannelMemberActorType };
+ content: string;
+ /** Stable references; URLs and document contents are resolved at execution time. */
+ fileIds?: string[];
+ id: string;
+ sequence: number;
+ threadId: string | null;
+}
+
+/**
+ * A run's input, frozen at claim time as a cutoff rather than a copy of the messages: the run
+ * receives new branch messages in (afterSequence, cutoffSequence], read on demand.
+ */
+export interface ChannelInputManifest {
+ /** Exclusive lower bound: already consumed public input in the continued topic. */
+ afterSequence: number;
+ /** Immutable at claim time; later public messages belong to the next run. */
+ cutoffSequence: number;
+ /** The member that triggered this run; its user is the execution identity. */
+ requesterMemberId: string;
+ requestMessageId: string;
+ /** Fixed at claim time. */
+ self: { agentId: string; memberId: string; name: string };
+ threadId: string | null;
+ /** Main-channel prefix visible to this branch; null for main. */
+ threadRootSequence: number | null;
+}
+
+/** Flat audit payload: routing decisions, claims, stops, isolation reasons. */
+export type ChannelAuditDetails = Record<string, boolean | number | string | string[] | null>;
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 307beb4d5a8..0e2cfd6f291 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -13,6 +13,7 @@ export * from './artifact';
export * from './asyncTask';
export * from './auth';
export * from './brief';
+export * from './channel';
export * from './chunk';
export * from './conversation';
export * from './creds';