The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 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 | // The shell's last executed run lookup sorts every run of the thread. This index carries |
| 8 | // that order and the same predicate the lookup filters on. A database that already has |
| 9 | // the index keeps it, so a hand-applied one does not fail the migration. |
| 10 | yield* sql` |
| 11 | CREATE INDEX IF NOT EXISTS orchestration_v2_projection_runs_last_executed_idx |
| 12 | ON orchestration_v2_projection_runs( |
| 13 | thread_id, (completed_at IS NULL) DESC, completed_at DESC, ordinal DESC, run_id DESC |
| 14 | ) |
| 15 | WHERE status <> 'queued' |
| 16 | AND NOT (status = 'cancelled' AND json_extract(payload_json, '$.startedAt') IS NULL) |
| 17 | `; |
| 18 | }); |