The best way to control Claude Code, Codex and more from any computer or phone
fix(server): dev database seed drops active pull request watches (#32744)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Nov 10, 2026 at 05:07 UTC
0a9abddaee00ff1495e77a03dd4fafa73c3cd4cb
2 files changed
+44
-2
apps/server/scripts/migrate-dev-db.test.ts
+37
-2
@@ -38,8 +38,33 @@ const createFixtureSource = Effect.fn("createMigrateDevDbFixtureSource")(functio
38
'{"lineage":{"parentThreadId":"stopped-thread","relationshipToParent":"fork","rootThreadId":"stopped-thread"}}';
39
const subagentPayload =
40
'{"lineage":{"parentThreadId":"subagent-parent","relationshipToParent":"subagent","rootThreadId":"subagent-parent"},"forkedFrom":{"type":"node","nodeId":"node-1"}}';
41
+ const watchedPayload = JSON.stringify({
42
+ pullRequests: [
43
+ {
44
+ host: "github.com",
45
+ repository: "owner/repo",
46
+ number: 7,
47
+ url: "https://github.com/owner/repo/pull/7",
48
+ source: "agent",
49
+ linkedAt: "2026-08-01T00:00:00.000Z",
50
+ snapshot: null,
51
+ stack: null,
52
+ watch: {
53
+ startedAt: "2026-08-01T00:00:00.000Z",
54
+ headSha: null,
55
+ failedChecks: [],
56
+ passed: false,
57
+ passedChecks: [],
58
+ remarksThrough: "2026-08-01T00:00:00.000Z",
59
+ remarkIds: [],
60
+ conflicting: false,
61
+ wakes: 0,
62
+ },
63
+ },
64
+ ],
65
+ });
66
const threads = [
42
- ["stopped-thread", "project-kept", "completed", "{}", "2026-08-01"],
67
+ ["stopped-thread", "project-kept", "completed", watchedPayload, "2026-08-01"],
68
["fork-thread", "project-kept", "completed", forkPayload, "2026-08-02"],
69
["running-thread", "project-kept", "running", "{}", "2026-08-05"],
70
["settled-thread", "project-kept", "completed", '{"settledAt":"2026-08-01"}', "2026-08-05"],
@@ -129,6 +154,11 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
154
SELECT stream_id FROM orchestration_events ORDER BY stream_id`;
155
const sessions = yield* sql<{ provider_session_id: string }>`
156
SELECT provider_session_id FROM orchestration_v2_projection_provider_sessions`;
157
+ const [pullRequest] = yield* sql<{ url: string | null; watch: string | null }>`
158
+ SELECT
159
+ json_extract(payload_json, '$.pullRequests[0].url') AS url,
160
+ json_extract(payload_json, '$.pullRequests[0].watch') AS watch
161
+ FROM orchestration_v2_projection_threads WHERE thread_id = 'stopped-thread'`;
162
const [leftovers] = yield* sql<{
163
auth: number;
164
tasks: number;
@@ -143,7 +173,7 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
173
(SELECT COUNT(*) FROM scheduled_task_webhook_pending) AS webhooks,
174
(SELECT COUNT(*) FROM orchestration_v2_projection_context_transfers) AS transfers,
175
(SELECT COUNT(*) FROM peer_environment_links) AS links`;
146
- return { threads, events, sessions, leftovers };
176
+ return { threads, events, sessions, pullRequest, leftovers };
177
}),
178
);
179
assert.deepStrictEqual(
@@ -158,6 +188,11 @@ it.layer(NodeServices.layer)("migrate-dev-db", (it) => {
188
kept.sessions.map((row) => row.provider_session_id),
189
["session-shared"],
190
);
191
+ assert.deepStrictEqual(
192
+ kept.pullRequest,
193
+ { url: "https://github.com/owner/repo/pull/7", watch: null },
194
+ "copied pull request links keep their history but stop being watched",
195
+ );
196
assert.deepStrictEqual(kept.leftovers, {
197
auth: 0,
198
tasks: 0,
apps/server/scripts/migrate-dev-db.ts
+7
@@ -381,6 +381,13 @@ const pruneSnapshot = Effect.fn("pruneDevDbSnapshot")(function* (input: RunMigra
381
AND stream_id NOT IN (SELECT thread_id FROM kept_threads))
382
OR (aggregate_kind = 'project'
383
AND stream_id NOT IN (SELECT project_id FROM kept_projects))`;
384
+ yield* sql`UPDATE orchestration_v2_projection_threads
385
+ SET payload_json = json_set(payload_json, '$.pullRequests', (
386
+ SELECT json_group_array(json_remove(link.value, '$.watch') ORDER BY link.key)
387
+ FROM json_each(payload_json, '$.pullRequests') AS link))
388
+ WHERE EXISTS (
389
+ SELECT 1 FROM json_each(payload_json, '$.pullRequests') AS link
390
+ WHERE json_extract(link.value, '$.watch') IS NOT NULL)`;
391
for (const table of CLEARED_TABLES) {
392
yield* sql`DELETE FROM ${sql(table)}`;
393
}