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

124_PullRequestThreadIndex.ts

15 lines699 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 // ProjectionStore.getThreadsWithPullRequests walks this instead of parsing every thread's
8 // payload. Keep the WHERE identical to that query's; archived_at lets active sweeps filter here.
9 yield* sql`
10 CREATE INDEX IF NOT EXISTS orchestration_v2_projection_threads_pull_requests_idx
11 ON orchestration_v2_projection_threads(updated_at, thread_id, archived_at)
12 WHERE deleted_at IS NULL
13 AND (CASE WHEN json_valid(payload_json) THEN json_type(payload_json, '$.pullRequests[0]') END) IS NOT NULL
14 `;
15});