Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): stop maintaining the unused event correlation index #23211

Mergedjuliusmarmingemerged 6 commits intomain fromrefs/pull/23211/headmerged by juliusmarminge View on GitHub

Showing 4 changed files with 50 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
10 additions and 0 deletionsapps/server/src/persistence/Migrations/078_DropOrchestrationEventCorrelationIndex.tsAdded
View file
@@ -0,0 +1,10 @@
+import * as Effect from "effect/Effect";
+import * as SqlClient from "effect/sql/SqlClient";
+​
+export default Effect.gen(function* () {
+ const sql = yield* SqlClient.SqlClient;
+​
+ // No query filters events by correlation_id, so this index only adds write
+ // and storage cost. The column and its values stay.
+ yield* sql`DROP INDEX IF EXISTS idx_orch_events_correlation_id`;
+});
38 additions and 0 deletionsapps/server/src/persistence/Migrations.test.tsModified
View file
@@ -78,6 +78,44 @@
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
);
​
+ it.effect("drops the unused correlation index and keeps correlation values", () =>
+ Effect.gen(function* () {
+ const sql = yield* SqlClient.SqlClient;
+ yield* runMigrations({ toMigrationInclusive: 54 });
+ yield* sql`
+ INSERT INTO orchestration_events (
+ event_id, aggregate_kind, stream_id, stream_version, event_type, occurred_at,
+ command_id, causation_event_id, correlation_id, actor_kind, payload_json, metadata_json
+ )
+ VALUES (
+ 'event-1', 'thread', 'thread-1', 0, 'thread.created', '2026-01-01T00:00:00.000Z',
+ 'command-1', NULL, 'correlation-1', 'client', '{}', '{}'
+ )