The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Effect from "effect/Effect"; |
| 2 | import * as SqlClient from "effect/sql/SqlClient"; |
| 3 | |
| 4 | export default Effect.gen(function* () { |
| 5 | const sql = yield* SqlClient.SqlClient; |
| 6 | |
| 7 | // Keep these expressions identical to ProjectionStore's shell worktree and family filters. |
| 8 | // json_valid keeps a malformed payload writable, as the other payload indexes do. |
| 9 | yield* sql` |
| 10 | CREATE INDEX IF NOT EXISTS orchestration_v2_projection_threads_worktree_path_idx |
| 11 | ON orchestration_v2_projection_threads( |
| 12 | CASE WHEN json_valid(payload_json) THEN json_extract(payload_json, '$.worktreePath') END |
| 13 | ) |
| 14 | `; |
| 15 | yield* sql` |
| 16 | CREATE INDEX IF NOT EXISTS orchestration_v2_projection_threads_root_thread_idx |
| 17 | ON orchestration_v2_projection_threads( |
| 18 | CASE WHEN json_valid(payload_json) THEN json_extract(payload_json, '$.lineage.rootThreadId') END |
| 19 | ) |
| 20 | `; |
| 21 | // Shell item counts read only a run's status; the primary key would load the whole row. |
| 22 | yield* sql` |
| 23 | CREATE INDEX IF NOT EXISTS orchestration_v2_projection_runs_run_status_idx |
| 24 | ON orchestration_v2_projection_runs(run_id, status) |
| 25 | `; |
| 26 | }); |