| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as SqlClient from "effect/sql/SqlClient"; |
| 3 | |
| 4 | // Schema setup composed by migration 055. |
| 5 | export default Effect.gen(function* () { |
| 6 | const sql = yield* SqlClient.SqlClient; |
| 7 | |
| 8 | yield* sql` |
| 9 | CREATE TABLE orchestration_v2_projection_subagents ( |
| 10 | subagent_id TEXT PRIMARY KEY, |
| 11 | thread_id TEXT NOT NULL, |
| 12 | run_id TEXT, |
| 13 | parent_node_id TEXT NOT NULL, |
| 14 | provider TEXT NOT NULL, |
| 15 | provider_thread_id TEXT, |
| 16 | child_thread_id TEXT, |
| 17 | origin TEXT NOT NULL, |
| 18 | status TEXT NOT NULL, |
| 19 | started_at TEXT, |
| 20 | completed_at TEXT, |
| 21 | updated_at TEXT NOT NULL, |
| 22 | payload_json TEXT NOT NULL |
| 23 | ) |
| 24 | `; |
| 25 | yield* sql`CREATE INDEX orchestration_v2_projection_subagents_thread_idx ON orchestration_v2_projection_subagents(thread_id, started_at, subagent_id)`; |
| 26 | yield* sql`CREATE INDEX orchestration_v2_projection_subagents_parent_node_idx ON orchestration_v2_projection_subagents(parent_node_id)`; |
| 27 | yield* sql`CREATE INDEX orchestration_v2_projection_subagents_provider_thread_idx ON orchestration_v2_projection_subagents(provider_thread_id)`; |
| 28 | yield* sql`CREATE INDEX orchestration_v2_projection_subagents_child_thread_idx ON orchestration_v2_projection_subagents(child_thread_id)`; |
| 29 | }); |