Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ShellIndexes.ts

23 lines916 Bytes

1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3​
4export default Effect.gen(function* () {
5 const sql = yield* SqlClient.SqlClient;
6​
7 yield* sql`
8 CREATE INDEX orchestration_v2_projection_turn_items_thread_run_idx
9 ON orchestration_v2_projection_turn_items(thread_id, run_id)
10 `;
11 // Keep this predicate aligned with ProjectionStore's pending-item query.
12 yield* sql`
13 CREATE INDEX orchestration_v2_projection_turn_items_shell_pending_idx
14 ON orchestration_v2_projection_turn_items(thread_id, run_id)
15 WHERE type IN ('command_execution', 'dynamic_tool', 'subagent')
16 AND status NOT IN ('completed', 'interrupted', 'failed', 'cancelled')
17 `;
18 yield* sql`
19 CREATE INDEX orchestration_v2_projection_messages_latest_user_idx
20 ON orchestration_v2_projection_messages(thread_id, updated_at DESC, message_id DESC)
21 WHERE role = 'user'
22 `;
23});