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 | /** |
| 5 | * A projection read groups a thread's message items by `$.messageId` for each message's first |
| 6 | * ordinal; without this index it parses every message item's payload. The expression and the |
| 7 | * WHERE must stay identical to that query's, or SQLite will not use the index. `json_valid` keeps |
| 8 | * a payload that is not JSON out of it: json_extract would fail its write. |
| 9 | */ |
| 10 | export default Effect.gen(function* () { |
| 11 | const sql = yield* SqlClient.SqlClient; |
| 12 | |
| 13 | yield* sql` |
| 14 | CREATE INDEX IF NOT EXISTS orchestration_v2_projection_turn_items_message_ordinal_idx |
| 15 | ON orchestration_v2_projection_turn_items( |
| 16 | thread_id, json_extract(payload_json, '$.messageId'), ordinal |
| 17 | ) |
| 18 | WHERE type IN ('user_message', 'assistant_message') AND json_valid(payload_json) |
| 19 | `; |
| 20 | }); |