Skip to content

Commit 9cda445

Browse files
committed
fix(server): custom-title migration skips an existing column
1 parent 7c54a04 commit 9cda445

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import * as SqlClient from "effect/sql/SqlClient";
33

44
export default Effect.gen(function* () {
55
const sql = yield* SqlClient.SqlClient;
6-
yield* sql`
7-
ALTER TABLE projection_projects
8-
ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0
6+
// Earlier builds of this change shipped the column under another migration id.
7+
const columns = yield* sql<{ readonly name: string }>`
8+
PRAGMA table_info(projection_projects)
99
`;
10+
if (!columns.some((column) => column.name === "has_custom_title")) {
11+
yield* sql`
12+
ALTER TABLE projection_projects
13+
ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0
14+
`;
15+
}
1016
yield* sql`
1117
UPDATE projection_projects
1218
SET has_custom_title = 1

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ describe("V2 preview upgrade", () => {
4545
'client', ${JSON.stringify(projectId === "renamed" ? { title: "repo" } : { autoPull: true })}, '{}', 2)
4646
`;
4747
}
48+
// Builds of this change before renumbering already added the column.
49+
yield* sql`ALTER TABLE projection_projects ADD COLUMN has_custom_title INTEGER NOT NULL DEFAULT 0`;
4850
yield* runMigrations();
4951
assert.deepStrictEqual(
5052
yield* sql`SELECT project_id, has_custom_title FROM projection_projects ORDER BY project_id`,

0 commit comments

Comments
 (0)