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

107_DeferredSlashCommandIndex.ts

17 lines788 Bytes

1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3​
4import { DEFERRED_COMMAND_MESSAGE_CONDITION } from "../../orchestration-v2/deferredCommandMessage.ts";
5​
6export default Effect.gen(function* () {
7 const sql = yield* SqlClient.SqlClient;
8​
9 // The turn-start read now matches every slash command; a partial index is only used when its
10 // predicate spells the read's condition, so rebuild the one migration 100 made.
11 yield* sql`DROP INDEX IF EXISTS orchestration_v2_projection_messages_deferred_command_idx`;
12 yield* sql.unsafe(`
13 CREATE INDEX orchestration_v2_projection_messages_deferred_command_idx
14 ON orchestration_v2_projection_messages(thread_id, created_at, message_id)
15 WHERE ${DEFERRED_COMMAND_MESSAGE_CONDITION}
16 `);
17});