You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CREATESCHEMAIF NOT EXISTS "trigger_dashboard_agent";
2
+
--> statement-breakpoint
3
+
CREATETABLEIF NOT EXISTS "trigger_dashboard_agent"."chat_sessions" (
4
+
"chat_id"textPRIMARY KEYNOT NULL,
5
+
"public_access_token"textNOT NULL,
6
+
"last_event_id"text,
7
+
"run_id"text,
8
+
"updated_at"timestamp with time zone DEFAULT now() NOT NULL
9
+
);
10
+
--> statement-breakpoint
11
+
CREATETABLEIF NOT EXISTS "trigger_dashboard_agent"."chats" (
12
+
"id"textPRIMARY KEYNOT NULL,
13
+
"organization_id"textNOT NULL,
14
+
"user_id"textNOT NULL,
15
+
"title"text DEFAULT 'New chat'NOT NULL,
16
+
"messages" jsonb DEFAULT '[]'::jsonb NOT NULL,
17
+
"metadata" jsonb DEFAULT '{}'::jsonb NOT NULL,
18
+
"pinned_at"timestamp with time zone,
19
+
"deleted_at"timestamp with time zone,
20
+
"last_message_at"timestamp with time zone,
21
+
"created_at"timestamp with time zone DEFAULT now() NOT NULL,
22
+
"updated_at"timestamp with time zone DEFAULT now() NOT NULL
23
+
);
24
+
--> statement-breakpoint
25
+
CREATEINDEXIF NOT EXISTS "chats_org_user_last_msg_idx"ON"trigger_dashboard_agent"."chats" USING btree ("organization_id","user_id","last_message_at"DESC NULLS LAST) WHERE"trigger_dashboard_agent"."chats"."deleted_at" is null;
CREATEINDEXIF NOT EXISTS "chat_turn_evals_org_created_idx"ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("organization_id","created_at"DESC NULLS LAST);--> statement-breakpoint
38
+
CREATEINDEXIF NOT EXISTS "chat_turn_evals_org_opps_idx"ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("organization_id","created_at"DESC NULLS LAST) WHERE"trigger_dashboard_agent"."chat_turn_evals"."capability_gap"or"trigger_dashboard_agent"."chat_turn_evals"."docs_gap"or"trigger_dashboard_agent"."chat_turn_evals"."support_opportunity"or"trigger_dashboard_agent"."chat_turn_evals"."feature_request";
"cadence_minutes"integer GENERATED ALWAYS AS (((spec ->>'checkEveryMinutes')::int)) STORED
148
87
);
149
88
--> statement-breakpoint
150
-
CREATEINDEX "chat_messages_chat_user_role_idx" ON"trigger_dashboard_agent"."chat_messages" USING btree ("chat_id","message_id") WHERE"trigger_dashboard_agent"."chat_messages"."role"='user';--> statement-breakpoint
151
-
CREATEINDEX "chat_turn_evals_org_created_idx" ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("organization_id","created_at"DESC NULLS LAST);--> statement-breakpoint
152
-
CREATEINDEX "chat_turn_evals_created_idx" ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("created_at");--> statement-breakpoint
153
-
CREATEINDEX "chat_turn_evals_org_opps_idx" ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("organization_id","created_at"DESC NULLS LAST) WHERE"trigger_dashboard_agent"."chat_turn_evals"."capability_gap"or"trigger_dashboard_agent"."chat_turn_evals"."docs_gap"or"trigger_dashboard_agent"."chat_turn_evals"."support_opportunity"or"trigger_dashboard_agent"."chat_turn_evals"."feature_request";--> statement-breakpoint
154
-
CREATEINDEX "chats_org_user_last_msg_idx" ON"trigger_dashboard_agent"."chats" USING btree ("organization_id","user_id","last_message_at"DESC NULLS LAST) WHERE"trigger_dashboard_agent"."chats"."deleted_at" is null;--> statement-breakpoint
155
-
CREATEINDEX "investigations_chat_idx" ON"trigger_dashboard_agent"."investigations" USING btree ("chat_id");--> statement-breakpoint
156
-
CREATEINDEX "investigations_open_updated_idx" ON"trigger_dashboard_agent"."investigations" USING btree ("updated_at") WHERE"trigger_dashboard_agent"."investigations"."state"->>'outcome'='in_progress';--> statement-breakpoint
157
-
CREATEINDEX "watch_submissions_created_idx" ON"trigger_dashboard_agent"."watch_submissions" USING btree ("created_at");--> statement-breakpoint
158
-
CREATEINDEX "watches_chat_idx" ON"trigger_dashboard_agent"."watches" USING btree ("chat_id");--> statement-breakpoint
159
-
CREATEUNIQUE INDEX "watches_chat_active_identity_key" ON"trigger_dashboard_agent"."watches" USING btree ("chat_id","project_id","environment_id","identity") WHERE"trigger_dashboard_agent"."watches"."status"='active';--> statement-breakpoint
160
-
CREATEINDEX "watches_status_expires_idx" ON"trigger_dashboard_agent"."watches" USING btree ("status","expires_at");--> statement-breakpoint
161
-
CREATEINDEX "watches_pending_delivery_idx" ON"trigger_dashboard_agent"."watches" USING btree ("fired_at","last_checked_at") WHERE"trigger_dashboard_agent"."watches"."delivery_status"in ('pending', 'delivering');--> statement-breakpoint
ALTERTABLE"trigger_dashboard_agent"."chats" DROP COLUMN IF EXISTS "messages";
90
+
--> statement-breakpoint
91
+
ALTERTABLE"trigger_dashboard_agent"."chats" ADD COLUMN IF NOT EXISTS "last_read_at"timestamp with time zone;
92
+
--> statement-breakpoint
93
+
ALTERTABLE"trigger_dashboard_agent"."chats" ADD COLUMN IF NOT EXISTS "next_message_position"integer DEFAULT 1NOT NULL;
94
+
--> statement-breakpoint
95
+
CREATEINDEX "chat_messages_chat_user_role_idx" ON"trigger_dashboard_agent"."chat_messages" USING btree ("chat_id","message_id") WHERE"trigger_dashboard_agent"."chat_messages"."role"='user';
96
+
--> statement-breakpoint
97
+
CREATEINDEX "chat_turn_evals_created_idx" ON"trigger_dashboard_agent"."chat_turn_evals" USING btree ("created_at");
98
+
--> statement-breakpoint
99
+
CREATEINDEX "investigations_chat_idx" ON"trigger_dashboard_agent"."investigations" USING btree ("chat_id");
100
+
--> statement-breakpoint
101
+
CREATEINDEX "investigations_open_updated_idx" ON"trigger_dashboard_agent"."investigations" USING btree ("updated_at") WHERE"trigger_dashboard_agent"."investigations"."state"->>'outcome'='in_progress';
102
+
--> statement-breakpoint
103
+
CREATEINDEX "watch_submissions_created_idx" ON"trigger_dashboard_agent"."watch_submissions" USING btree ("created_at");
104
+
--> statement-breakpoint
105
+
CREATEINDEX "watches_chat_idx" ON"trigger_dashboard_agent"."watches" USING btree ("chat_id");
106
+
--> statement-breakpoint
107
+
CREATEUNIQUE INDEX "watches_chat_active_identity_key" ON"trigger_dashboard_agent"."watches" USING btree ("chat_id","project_id","environment_id","identity") WHERE"trigger_dashboard_agent"."watches"."status"='active';
108
+
--> statement-breakpoint
109
+
CREATEINDEX "watches_status_expires_idx" ON"trigger_dashboard_agent"."watches" USING btree ("status","expires_at");
110
+
--> statement-breakpoint
111
+
CREATEINDEX "watches_pending_delivery_idx" ON"trigger_dashboard_agent"."watches" USING btree ("fired_at","last_checked_at") WHERE"trigger_dashboard_agent"."watches"."delivery_status"in ('pending', 'delivering');
0 commit comments