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, 23:30 UTC
fix(server): peer link migrations 71 and 72 rerun safely (#26834)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 11, 2026 at 11:55 UTC
c75a58e57cd8ebe213161bb752187cdafeb39d5c
3 files changed
+23
-4
apps/server/src/persistence/Migrations.test.ts
+14
@@ -151,6 +151,20 @@ describe("runMigrations", () => {
151
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
152
);
153
154
+ it.effect("reapplies peer link migrations whose ledger rows are missing", () =>
155
+ Effect.gen(function* () {
156
+ const sql = yield* SqlClient.SqlClient;
157
+ yield* runMigrations({ toMigrationInclusive: 72 });
158
+ yield* sql`DELETE FROM effect_sql_migrations WHERE migration_id BETWEEN 70 AND 72`;
159
+
160
+ assert.deepStrictEqual(
161
+ yield* runMigrations(),
162
+ migrationManifest.filter(([id]) => id >= 70),
163
+ );
164
+ assert.deepStrictEqual(yield* history, migrationManifest);
165
+ }).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
166
+ );
167
+
168
it.effect("still starts after a newer build recorded a later V2 migration", () =>
169
Effect.gen(function* () {
170
const sql = yield* SqlClient.SqlClient;
apps/server/src/persistence/Migrations/071_PeerLinkFence.ts
+8
-3
@@ -3,10 +3,15 @@ import * as SqlClient from "effect/sql/SqlClient";
3
4
export default Effect.gen(function* () {
5
const sql = yield* SqlClient.SqlClient;
6
+ const columns = yield* sql<{ readonly name: string }>`
7
+ PRAGMA table_info(peer_environment_links)
8
+ `;
9
10
// Whether the link's session was issued as a link, which the peer fences.
11
// Links stored before it are not, and must be made again.
9
- yield* sql`
10
- ALTER TABLE peer_environment_links ADD COLUMN fenced INTEGER NOT NULL DEFAULT 0
11
- `;
12
+ if (!columns.some((column) => column.name === "fenced")) {
13
+ yield* sql`
14
+ ALTER TABLE peer_environment_links ADD COLUMN fenced INTEGER NOT NULL DEFAULT 0
15
+ `;
16
+ }
17
});
apps/server/src/persistence/Migrations/072_WaitingLinkRequestIndex.ts
+1
-1
@@ -6,7 +6,7 @@ export default Effect.gen(function* () {
6
7
// Keep this predicate aligned with ProjectionStore's waiting link card query.
8
yield* sql`
9
- CREATE INDEX orchestration_v2_projection_turn_items_waiting_link_idx
9
+ CREATE INDEX IF NOT EXISTS orchestration_v2_projection_turn_items_waiting_link_idx
10
ON orchestration_v2_projection_turn_items(thread_id, updated_at DESC, turn_item_id DESC)
11
WHERE type = 'link_request' AND status = 'waiting'
12
`;