Skip to content

Commit 759c2a0

Browse files
fix(server): retain recorded project renames during upgrade
Co-authored-by: MacKinley Smith <[email protected]>
1 parent 5ade754 commit 759c2a0

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

‎apps/server/src/persistence/Migrations/070_ProjectionProjectsCustomTitle.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,14 @@ export default Effect.gen(function* () {
77
ALTER TABLE projection_projects
88
ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0
99
`;
10+
yield* sql`
11+
UPDATE projection_projects
12+
SET has_custom_title = 1
13+
WHERE project_id IN (
14+
SELECT stream_id FROM orchestration_events
15+
WHERE aggregate_kind = 'project'
16+
AND event_type = 'project.meta-updated'
17+
AND json_type(payload_json, '$.title') = 'text'
18+
)
19+
`;
1020
});

‎apps/server/src/persistence/reconcileV2PreviewMigration.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,35 @@ const seedPreview = Effect.gen(function* () {
2727
});
2828

2929
describe("V2 preview upgrade", () => {
30+
it.effect("preserves recorded project renames when adding custom-title state", () =>
31+
Effect.gen(function* () {
32+
const sql = yield* SqlClient.SqlClient;
33+
yield* runMigrations({ toMigrationInclusive: 69 });
34+
for (const projectId of ["renamed", "untouched"]) {
35+
yield* sql`
36+
INSERT INTO projection_projects
37+
(project_id, title, workspace_root, scripts_json, created_at, updated_at)
38+
VALUES (${projectId}, 'repo', ${"/tmp/" + projectId}, '[]', '2026-10-01', '2026-10-01')
39+
`;
40+
yield* sql`
41+
INSERT INTO orchestration_events
42+
(event_id, aggregate_kind, stream_id, stream_version, event_type, occurred_at,
43+
actor_kind, payload_json, metadata_json, application_event_version)
44+
VALUES (${projectId}, 'project', ${projectId}, 1, 'project.meta-updated', '2026-10-01',
45+
'client', ${JSON.stringify(projectId === "renamed" ? { title: "repo" } : { autoPull: true })}, '{}', 2)
46+
`;
47+
}
48+
yield* runMigrations();
49+
assert.deepStrictEqual(
50+
yield* sql`SELECT project_id, has_custom_title FROM projection_projects ORDER BY project_id`,
51+
[
52+
{ project_id: "renamed", has_custom_title: 1 },
53+
{ project_id: "untouched", has_custom_title: 0 },
54+
],
55+
);
56+
}).pipe(Effect.provide(NodeSqliteClient.layer({ filename: ":memory:" }))),
57+
);
58+
3059
it.effect("upgrades a published preview without replaying V2 or losing import progress", () =>
3160
Effect.gen(function* () {
3261
const sql = yield* SqlClient.SqlClient;

0 commit comments

Comments
 (0)