@rudderhq/db 0.3.5-canary.8 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/migrations/0088_curly_sue_storm.sql +30 -0
- package/dist/migrations/0089_goofy_peter_parker.sql +1 -0
- package/dist/migrations/0090_chat_agent_runs.sql +110 -0
- package/dist/migrations/0091_disabled_intelligence_profiles.sql +8 -0
- package/dist/migrations/0092_white_tombstone.sql +139 -0
- package/dist/migrations/meta/0088_snapshot.json +15724 -0
- package/dist/migrations/meta/0089_snapshot.json +15730 -0
- package/dist/migrations/meta/0090_snapshot.json +15838 -0
- package/dist/migrations/meta/0091_snapshot.json +15838 -0
- package/dist/migrations/meta/0092_snapshot.json +17120 -0
- package/dist/migrations/meta/_journal.json +35 -0
- package/dist/schema/agent_integration_binding_tokens.d.ts +161 -0
- package/dist/schema/agent_integration_binding_tokens.d.ts.map +1 -0
- package/dist/schema/agent_integration_binding_tokens.js +21 -0
- package/dist/schema/agent_integration_binding_tokens.js.map +1 -0
- package/dist/schema/agent_integration_chat_bindings.d.ts +144 -0
- package/dist/schema/agent_integration_chat_bindings.d.ts.map +1 -0
- package/dist/schema/agent_integration_chat_bindings.js +22 -0
- package/dist/schema/agent_integration_chat_bindings.js.map +1 -0
- package/dist/schema/agent_integration_inbound_audit.d.ts +231 -0
- package/dist/schema/agent_integration_inbound_audit.d.ts.map +1 -0
- package/dist/schema/agent_integration_inbound_audit.js +23 -0
- package/dist/schema/agent_integration_inbound_audit.js.map +1 -0
- package/dist/schema/agent_integration_inbound_dedup.d.ts +110 -0
- package/dist/schema/agent_integration_inbound_dedup.d.ts.map +1 -0
- package/dist/schema/agent_integration_inbound_dedup.js +19 -0
- package/dist/schema/agent_integration_inbound_dedup.js.map +1 -0
- package/dist/schema/agent_integration_outbound_messages.d.ts +229 -0
- package/dist/schema/agent_integration_outbound_messages.d.ts.map +1 -0
- package/dist/schema/agent_integration_outbound_messages.js +30 -0
- package/dist/schema/agent_integration_outbound_messages.js.map +1 -0
- package/dist/schema/agent_integration_user_bindings.d.ts +178 -0
- package/dist/schema/agent_integration_user_bindings.d.ts.map +1 -0
- package/dist/schema/agent_integration_user_bindings.js +22 -0
- package/dist/schema/agent_integration_user_bindings.js.map +1 -0
- package/dist/schema/agent_integrations.d.ts +297 -0
- package/dist/schema/agent_integrations.d.ts.map +1 -0
- package/dist/schema/agent_integrations.js +31 -0
- package/dist/schema/agent_integrations.js.map +1 -0
- package/dist/schema/chat_messages.d.ts +17 -0
- package/dist/schema/chat_messages.d.ts.map +1 -1
- package/dist/schema/chat_messages.js +3 -0
- package/dist/schema/chat_messages.js.map +1 -1
- package/dist/schema/heartbeat_runs.d.ts +17 -0
- package/dist/schema/heartbeat_runs.d.ts.map +1 -1
- package/dist/schema/heartbeat_runs.js +10 -1
- package/dist/schema/heartbeat_runs.js.map +1 -1
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +8 -0
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/messenger_custom_groups.d.ts +304 -0
- package/dist/schema/messenger_custom_groups.d.ts.map +1 -0
- package/dist/schema/messenger_custom_groups.js +36 -0
- package/dist/schema/messenger_custom_groups.js.map +1 -0
- package/dist/schema/organization_intelligence_profiles.js +1 -1
- package/dist/schema/organization_intelligence_profiles.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
CREATE TABLE "messenger_custom_group_entries" (
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
+
"org_id" uuid NOT NULL,
|
|
4
|
+
"user_id" text NOT NULL,
|
|
5
|
+
"group_id" uuid NOT NULL,
|
|
6
|
+
"thread_key" text NOT NULL,
|
|
7
|
+
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
8
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
9
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
10
|
+
);
|
|
11
|
+
--> statement-breakpoint
|
|
12
|
+
CREATE TABLE "messenger_custom_groups" (
|
|
13
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
14
|
+
"org_id" uuid NOT NULL,
|
|
15
|
+
"user_id" text NOT NULL,
|
|
16
|
+
"name" text NOT NULL,
|
|
17
|
+
"sort_order" integer DEFAULT 0 NOT NULL,
|
|
18
|
+
"collapsed" boolean DEFAULT false NOT NULL,
|
|
19
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
20
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
21
|
+
CONSTRAINT "messenger_custom_groups_org_user_id_unique" UNIQUE("org_id","user_id","id")
|
|
22
|
+
);
|
|
23
|
+
--> statement-breakpoint
|
|
24
|
+
ALTER TABLE "messenger_custom_group_entries" ADD CONSTRAINT "messenger_custom_group_entries_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
25
|
+
ALTER TABLE "messenger_custom_group_entries" ADD CONSTRAINT "messenger_custom_group_entries_owner_group_fk" FOREIGN KEY ("org_id","user_id","group_id") REFERENCES "public"."messenger_custom_groups"("org_id","user_id","id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
26
|
+
ALTER TABLE "messenger_custom_groups" ADD CONSTRAINT "messenger_custom_groups_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
27
|
+
CREATE INDEX "messenger_custom_group_entries_org_user_group_idx" ON "messenger_custom_group_entries" USING btree ("org_id","user_id","group_id","sort_order");--> statement-breakpoint
|
|
28
|
+
CREATE UNIQUE INDEX "messenger_custom_group_entries_org_user_thread_idx" ON "messenger_custom_group_entries" USING btree ("org_id","user_id","thread_key");--> statement-breakpoint
|
|
29
|
+
CREATE INDEX "messenger_custom_groups_org_user_idx" ON "messenger_custom_groups" USING btree ("org_id","user_id");--> statement-breakpoint
|
|
30
|
+
CREATE INDEX "messenger_custom_groups_org_user_order_idx" ON "messenger_custom_groups" USING btree ("org_id","user_id","sort_order");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TABLE "messenger_custom_groups" ADD COLUMN "icon" text;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
ALTER TABLE "heartbeat_runs" ADD COLUMN "chat_conversation_id" uuid;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE "chat_messages" ADD COLUMN "run_id" uuid;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE "heartbeat_runs" ADD CONSTRAINT "heartbeat_runs_chat_conversation_id_chat_conversations_id_fk" FOREIGN KEY ("chat_conversation_id") REFERENCES "public"."chat_conversations"("id") ON DELETE set null ON UPDATE no action;
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
ALTER TABLE "chat_messages" ADD CONSTRAINT "chat_messages_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;
|
|
8
|
+
--> statement-breakpoint
|
|
9
|
+
CREATE INDEX "heartbeat_runs_company_chat_conversation_status_updated_idx" ON "heartbeat_runs" USING btree ("org_id","chat_conversation_id","status","updated_at");
|
|
10
|
+
--> statement-breakpoint
|
|
11
|
+
CREATE INDEX "chat_messages_run_idx" ON "chat_messages" USING btree ("run_id");
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE UNIQUE INDEX "heartbeat_runs_active_chat_conversation_uq" ON "heartbeat_runs" USING btree ("org_id","chat_conversation_id") WHERE "chat_conversation_id" IS NOT NULL AND "status" IN ('queued','running');
|
|
14
|
+
--> statement-breakpoint
|
|
15
|
+
DO $$
|
|
16
|
+
DECLARE
|
|
17
|
+
batch_size integer := 1000;
|
|
18
|
+
processed integer := 0;
|
|
19
|
+
total_processed integer := 0;
|
|
20
|
+
BEGIN
|
|
21
|
+
LOOP
|
|
22
|
+
WITH candidates AS (
|
|
23
|
+
SELECT
|
|
24
|
+
m.id AS message_id,
|
|
25
|
+
gen_random_uuid() AS run_id,
|
|
26
|
+
m.org_id,
|
|
27
|
+
m.replying_agent_id AS agent_id,
|
|
28
|
+
m.conversation_id AS chat_conversation_id,
|
|
29
|
+
c.primary_issue_id,
|
|
30
|
+
c.plan_mode,
|
|
31
|
+
m.chat_turn_id,
|
|
32
|
+
m.turn_variant,
|
|
33
|
+
m.created_at,
|
|
34
|
+
m.updated_at
|
|
35
|
+
FROM "chat_messages" m
|
|
36
|
+
INNER JOIN "chat_conversations" c ON c.id = m.conversation_id
|
|
37
|
+
WHERE m.run_id IS NULL
|
|
38
|
+
AND m.role = 'assistant'
|
|
39
|
+
AND m.replying_agent_id IS NOT NULL
|
|
40
|
+
ORDER BY m.created_at, m.id
|
|
41
|
+
LIMIT batch_size
|
|
42
|
+
),
|
|
43
|
+
inserted AS (
|
|
44
|
+
INSERT INTO "heartbeat_runs" (
|
|
45
|
+
"id",
|
|
46
|
+
"org_id",
|
|
47
|
+
"agent_id",
|
|
48
|
+
"invocation_source",
|
|
49
|
+
"trigger_detail",
|
|
50
|
+
"status",
|
|
51
|
+
"started_at",
|
|
52
|
+
"finished_at",
|
|
53
|
+
"chat_conversation_id",
|
|
54
|
+
"context_snapshot",
|
|
55
|
+
"result_json",
|
|
56
|
+
"created_at",
|
|
57
|
+
"updated_at"
|
|
58
|
+
)
|
|
59
|
+
SELECT
|
|
60
|
+
run_id,
|
|
61
|
+
org_id,
|
|
62
|
+
agent_id,
|
|
63
|
+
'chat',
|
|
64
|
+
'chat_assistant_reply',
|
|
65
|
+
'succeeded',
|
|
66
|
+
created_at,
|
|
67
|
+
updated_at,
|
|
68
|
+
chat_conversation_id,
|
|
69
|
+
jsonb_build_object(
|
|
70
|
+
'scene', 'chat',
|
|
71
|
+
'conversationId', chat_conversation_id,
|
|
72
|
+
'assistantMessageId', message_id,
|
|
73
|
+
'chatTurnId', chat_turn_id,
|
|
74
|
+
'turnVariant', coalesce(turn_variant, 0),
|
|
75
|
+
'issueId', primary_issue_id,
|
|
76
|
+
'linkedIssueIds', CASE
|
|
77
|
+
WHEN primary_issue_id IS NULL THEN '[]'::jsonb
|
|
78
|
+
ELSE jsonb_build_array(primary_issue_id)
|
|
79
|
+
END,
|
|
80
|
+
'projectId', NULL,
|
|
81
|
+
'planMode', plan_mode,
|
|
82
|
+
'stream', false,
|
|
83
|
+
'controlIntent', 'backfill'
|
|
84
|
+
),
|
|
85
|
+
jsonb_build_object(
|
|
86
|
+
'outcome', 'completed',
|
|
87
|
+
'backfilled', true,
|
|
88
|
+
'assistantMessageId', message_id
|
|
89
|
+
),
|
|
90
|
+
created_at,
|
|
91
|
+
updated_at
|
|
92
|
+
FROM candidates
|
|
93
|
+
RETURNING id
|
|
94
|
+
),
|
|
95
|
+
updated AS (
|
|
96
|
+
UPDATE "chat_messages" m
|
|
97
|
+
SET "run_id" = c.run_id
|
|
98
|
+
FROM candidates c
|
|
99
|
+
WHERE m.id = c.message_id
|
|
100
|
+
AND m.run_id IS NULL
|
|
101
|
+
AND EXISTS (SELECT 1 FROM inserted i WHERE i.id = c.run_id)
|
|
102
|
+
RETURNING m.id
|
|
103
|
+
)
|
|
104
|
+
SELECT count(*) INTO processed FROM updated;
|
|
105
|
+
|
|
106
|
+
total_processed := total_processed + processed;
|
|
107
|
+
RAISE NOTICE '0090_chat_agent_runs backfilled % chat assistant message run links (% total)', processed, total_processed;
|
|
108
|
+
EXIT WHEN processed < batch_size;
|
|
109
|
+
END LOOP;
|
|
110
|
+
END $$;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
ALTER TABLE "organization_intelligence_profiles" ALTER COLUMN "status" SET DEFAULT 'disabled';
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
UPDATE "organization_intelligence_profiles"
|
|
4
|
+
SET
|
|
5
|
+
"status" = 'disabled',
|
|
6
|
+
"last_error" = 'Runtime chain must be tested before enabling.',
|
|
7
|
+
"updated_at" = now()
|
|
8
|
+
WHERE "status" = 'configured' AND "last_verified_at" IS NULL;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
CREATE TABLE "agent_integration_binding_tokens" (
|
|
2
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
3
|
+
"org_id" uuid NOT NULL,
|
|
4
|
+
"integration_id" uuid NOT NULL,
|
|
5
|
+
"token_hash" text NOT NULL,
|
|
6
|
+
"external_open_id" text NOT NULL,
|
|
7
|
+
"external_union_id" text,
|
|
8
|
+
"expires_at" timestamp with time zone NOT NULL,
|
|
9
|
+
"consumed_at" timestamp with time zone,
|
|
10
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
11
|
+
);
|
|
12
|
+
--> statement-breakpoint
|
|
13
|
+
CREATE TABLE "agent_integration_chat_bindings" (
|
|
14
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
15
|
+
"org_id" uuid NOT NULL,
|
|
16
|
+
"integration_id" uuid NOT NULL,
|
|
17
|
+
"conversation_id" uuid NOT NULL,
|
|
18
|
+
"external_chat_id" text NOT NULL,
|
|
19
|
+
"external_chat_type" text NOT NULL,
|
|
20
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
21
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
22
|
+
);
|
|
23
|
+
--> statement-breakpoint
|
|
24
|
+
CREATE TABLE "agent_integration_inbound_audit" (
|
|
25
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
26
|
+
"org_id" uuid,
|
|
27
|
+
"integration_id" uuid,
|
|
28
|
+
"provider" text NOT NULL,
|
|
29
|
+
"external_chat_id" text,
|
|
30
|
+
"external_chat_type" text,
|
|
31
|
+
"external_event_id" text,
|
|
32
|
+
"external_message_id" text,
|
|
33
|
+
"sender_open_id" text,
|
|
34
|
+
"drop_reason" text NOT NULL,
|
|
35
|
+
"body_persisted" boolean DEFAULT false NOT NULL,
|
|
36
|
+
"metadata" jsonb,
|
|
37
|
+
"received_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
38
|
+
);
|
|
39
|
+
--> statement-breakpoint
|
|
40
|
+
CREATE TABLE "agent_integration_inbound_dedup" (
|
|
41
|
+
"org_id" uuid,
|
|
42
|
+
"integration_id" uuid,
|
|
43
|
+
"provider" text NOT NULL,
|
|
44
|
+
"external_message_id" text NOT NULL,
|
|
45
|
+
"external_event_id" text,
|
|
46
|
+
"received_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
47
|
+
CONSTRAINT "agent_integration_inbound_dedup_pk" PRIMARY KEY("provider","external_message_id")
|
|
48
|
+
);
|
|
49
|
+
--> statement-breakpoint
|
|
50
|
+
CREATE TABLE "agent_integration_outbound_messages" (
|
|
51
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
52
|
+
"org_id" uuid NOT NULL,
|
|
53
|
+
"integration_id" uuid NOT NULL,
|
|
54
|
+
"conversation_id" uuid,
|
|
55
|
+
"chat_message_id" uuid,
|
|
56
|
+
"issue_id" uuid,
|
|
57
|
+
"run_id" uuid,
|
|
58
|
+
"external_chat_id" text NOT NULL,
|
|
59
|
+
"external_message_id" text,
|
|
60
|
+
"status" text DEFAULT 'pending' NOT NULL,
|
|
61
|
+
"last_patched_at" timestamp with time zone,
|
|
62
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
63
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
64
|
+
);
|
|
65
|
+
--> statement-breakpoint
|
|
66
|
+
CREATE TABLE "agent_integration_user_bindings" (
|
|
67
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
68
|
+
"org_id" uuid NOT NULL,
|
|
69
|
+
"integration_id" uuid NOT NULL,
|
|
70
|
+
"user_id" text NOT NULL,
|
|
71
|
+
"external_open_id" text NOT NULL,
|
|
72
|
+
"external_union_id" text,
|
|
73
|
+
"bound_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
74
|
+
"revoked_at" timestamp with time zone,
|
|
75
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
76
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
77
|
+
);
|
|
78
|
+
--> statement-breakpoint
|
|
79
|
+
CREATE TABLE "agent_integrations" (
|
|
80
|
+
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
|
81
|
+
"org_id" uuid NOT NULL,
|
|
82
|
+
"agent_id" uuid NOT NULL,
|
|
83
|
+
"provider" text NOT NULL,
|
|
84
|
+
"status" text DEFAULT 'active' NOT NULL,
|
|
85
|
+
"transport" text DEFAULT 'long_connection' NOT NULL,
|
|
86
|
+
"provider_region" text DEFAULT 'feishu_cn' NOT NULL,
|
|
87
|
+
"app_credential_secret_id" uuid NOT NULL,
|
|
88
|
+
"external_app_id" text NOT NULL,
|
|
89
|
+
"external_bot_open_id" text,
|
|
90
|
+
"external_tenant_key" text,
|
|
91
|
+
"installer_user_id" text,
|
|
92
|
+
"manage_url" text,
|
|
93
|
+
"installed_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
94
|
+
"revoked_at" timestamp with time zone,
|
|
95
|
+
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
96
|
+
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
97
|
+
);
|
|
98
|
+
--> statement-breakpoint
|
|
99
|
+
ALTER TABLE "agent_integration_binding_tokens" ADD CONSTRAINT "agent_integration_binding_tokens_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
100
|
+
ALTER TABLE "agent_integration_binding_tokens" ADD CONSTRAINT "agent_integration_binding_tokens_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
101
|
+
ALTER TABLE "agent_integration_chat_bindings" ADD CONSTRAINT "agent_integration_chat_bindings_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
102
|
+
ALTER TABLE "agent_integration_chat_bindings" ADD CONSTRAINT "agent_integration_chat_bindings_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
103
|
+
ALTER TABLE "agent_integration_chat_bindings" ADD CONSTRAINT "agent_integration_chat_bindings_conversation_id_chat_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."chat_conversations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
104
|
+
ALTER TABLE "agent_integration_inbound_audit" ADD CONSTRAINT "agent_integration_inbound_audit_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
105
|
+
ALTER TABLE "agent_integration_inbound_audit" ADD CONSTRAINT "agent_integration_inbound_audit_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
106
|
+
ALTER TABLE "agent_integration_inbound_dedup" ADD CONSTRAINT "agent_integration_inbound_dedup_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
107
|
+
ALTER TABLE "agent_integration_inbound_dedup" ADD CONSTRAINT "agent_integration_inbound_dedup_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
108
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
109
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
110
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_conversation_id_chat_conversations_id_fk" FOREIGN KEY ("conversation_id") REFERENCES "public"."chat_conversations"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
111
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_chat_message_id_chat_messages_id_fk" FOREIGN KEY ("chat_message_id") REFERENCES "public"."chat_messages"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
112
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_issue_id_issues_id_fk" FOREIGN KEY ("issue_id") REFERENCES "public"."issues"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
113
|
+
ALTER TABLE "agent_integration_outbound_messages" ADD CONSTRAINT "agent_integration_outbound_messages_run_id_heartbeat_runs_id_fk" FOREIGN KEY ("run_id") REFERENCES "public"."heartbeat_runs"("id") ON DELETE set null ON UPDATE no action;--> statement-breakpoint
|
|
114
|
+
ALTER TABLE "agent_integration_user_bindings" ADD CONSTRAINT "agent_integration_user_bindings_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
115
|
+
ALTER TABLE "agent_integration_user_bindings" ADD CONSTRAINT "agent_integration_user_bindings_integration_id_agent_integrations_id_fk" FOREIGN KEY ("integration_id") REFERENCES "public"."agent_integrations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
116
|
+
ALTER TABLE "agent_integrations" ADD CONSTRAINT "agent_integrations_org_id_organizations_id_fk" FOREIGN KEY ("org_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
117
|
+
ALTER TABLE "agent_integrations" ADD CONSTRAINT "agent_integrations_agent_id_agents_id_fk" FOREIGN KEY ("agent_id") REFERENCES "public"."agents"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
|
|
118
|
+
ALTER TABLE "agent_integrations" ADD CONSTRAINT "agent_integrations_app_credential_secret_id_organization_secrets_id_fk" FOREIGN KEY ("app_credential_secret_id") REFERENCES "public"."organization_secrets"("id") ON DELETE restrict ON UPDATE no action;--> statement-breakpoint
|
|
119
|
+
CREATE UNIQUE INDEX "agent_integration_binding_tokens_token_hash_uq" ON "agent_integration_binding_tokens" USING btree ("token_hash");--> statement-breakpoint
|
|
120
|
+
CREATE INDEX "agent_integration_binding_tokens_integration_open_id_idx" ON "agent_integration_binding_tokens" USING btree ("integration_id","external_open_id");--> statement-breakpoint
|
|
121
|
+
CREATE INDEX "agent_integration_binding_tokens_expiry_idx" ON "agent_integration_binding_tokens" USING btree ("expires_at");--> statement-breakpoint
|
|
122
|
+
CREATE INDEX "agent_integration_chat_bindings_org_conversation_idx" ON "agent_integration_chat_bindings" USING btree ("org_id","conversation_id");--> statement-breakpoint
|
|
123
|
+
CREATE UNIQUE INDEX "agent_integration_chat_bindings_integration_external_chat_uq" ON "agent_integration_chat_bindings" USING btree ("integration_id","external_chat_id");--> statement-breakpoint
|
|
124
|
+
CREATE INDEX "agent_integration_inbound_audit_org_reason_received_idx" ON "agent_integration_inbound_audit" USING btree ("org_id","drop_reason","received_at");--> statement-breakpoint
|
|
125
|
+
CREATE INDEX "agent_integration_inbound_audit_integration_received_idx" ON "agent_integration_inbound_audit" USING btree ("integration_id","received_at");--> statement-breakpoint
|
|
126
|
+
CREATE INDEX "agent_integration_inbound_audit_message_idx" ON "agent_integration_inbound_audit" USING btree ("provider","external_message_id");--> statement-breakpoint
|
|
127
|
+
CREATE INDEX "agent_integration_inbound_dedup_org_received_idx" ON "agent_integration_inbound_dedup" USING btree ("org_id","received_at");--> statement-breakpoint
|
|
128
|
+
CREATE INDEX "agent_integration_inbound_dedup_integration_received_idx" ON "agent_integration_inbound_dedup" USING btree ("integration_id","received_at");--> statement-breakpoint
|
|
129
|
+
CREATE INDEX "agent_integration_outbound_messages_org_status_idx" ON "agent_integration_outbound_messages" USING btree ("org_id","status");--> statement-breakpoint
|
|
130
|
+
CREATE INDEX "agent_integration_outbound_messages_run_idx" ON "agent_integration_outbound_messages" USING btree ("run_id");--> statement-breakpoint
|
|
131
|
+
CREATE INDEX "agent_integration_outbound_messages_issue_idx" ON "agent_integration_outbound_messages" USING btree ("issue_id");--> statement-breakpoint
|
|
132
|
+
CREATE UNIQUE INDEX "agent_integration_outbound_messages_integration_external_message_uq" ON "agent_integration_outbound_messages" USING btree ("integration_id","external_message_id");--> statement-breakpoint
|
|
133
|
+
CREATE INDEX "agent_integration_user_bindings_org_user_idx" ON "agent_integration_user_bindings" USING btree ("org_id","user_id");--> statement-breakpoint
|
|
134
|
+
CREATE UNIQUE INDEX "agent_integration_user_bindings_integration_open_id_uq" ON "agent_integration_user_bindings" USING btree ("integration_id","external_open_id");--> statement-breakpoint
|
|
135
|
+
CREATE INDEX "agent_integration_user_bindings_integration_union_id_idx" ON "agent_integration_user_bindings" USING btree ("integration_id","external_union_id");--> statement-breakpoint
|
|
136
|
+
CREATE INDEX "agent_integrations_org_provider_idx" ON "agent_integrations" USING btree ("org_id","provider");--> statement-breakpoint
|
|
137
|
+
CREATE UNIQUE INDEX "agent_integrations_org_agent_provider_uq" ON "agent_integrations" USING btree ("org_id","agent_id","provider");--> statement-breakpoint
|
|
138
|
+
CREATE UNIQUE INDEX "agent_integrations_org_provider_external_app_uq" ON "agent_integrations" USING btree ("org_id","provider","external_app_id");--> statement-breakpoint
|
|
139
|
+
CREATE INDEX "agent_integrations_secret_idx" ON "agent_integrations" USING btree ("app_credential_secret_id");
|