Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/server/src/persistence/Migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ import Migration0107 from "./Migrations/107_DeferredSlashCommandIndex.ts";
import Migration0108 from "./Migrations/108_AgentFeedback.ts";
import Migration0109 from "./Migrations/109_IssueTrackerAccounts.ts";
import Migration0110 from "./Migrations/110_Workflows.ts";
import Migration0111 from "./Migrations/111_SupersededRunAttemptIndex.ts";

const migrationEntries = [
[1, "OrchestrationEvents", Migration0001],
Expand Down Expand Up @@ -231,6 +232,7 @@ const migrationEntries = [
[108, "AgentFeedback", Migration0108],
[109, "IssueTrackerAccounts", Migration0109],
[110, "Workflows", Migration0110],
[111, "SupersededRunAttemptIndex", Migration0111],
] as const;

export const migrationManifest = migrationEntries.map(([id, name]) => [id, name] as const);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as Effect from "effect/Effect";
import * as SqlClient from "effect/sql/SqlClient";

export default Effect.gen(function* () {
const sql = yield* SqlClient.SqlClient;

// Opening a thread's history looks up its few superseded attempts. Without this index that
// reads every attempt row of the thread, which is slow on a long thread with a cold cache.
yield* sql`
CREATE INDEX IF NOT EXISTS orchestration_v2_projection_run_attempts_superseded_idx
ON orchestration_v2_projection_run_attempts(thread_id, run_id, root_node_id)
WHERE status = 'superseded'
`;
});
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ describe("V2 preview upgrade", () => {
[108, "AgentFeedback"],
[109, "IssueTrackerAccounts"],
[110, "Workflows"],
[111, "SupersededRunAttemptIndex"],
]);
assert.deepStrictEqual(yield* runMigrations(), []);
assert.deepStrictEqual(yield* sql`SELECT * FROM orchestration_v2_legacy_imports`, imports);
Expand Down Expand Up @@ -223,6 +224,7 @@ describe("V2 preview upgrade", () => {
[108, "AgentFeedback"],
[109, "IssueTrackerAccounts"],
[110, "Workflows"],
[111, "SupersededRunAttemptIndex"],
]);
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
);
Expand Down
Loading