From 6bd3a769c5758aa374c1673aff01affc5e3779f1 Mon Sep 17 00:00:00 2001 From: joaovictor91123 Date: Sun, 26 Jul 2026 06:42:48 -0700 Subject: [PATCH] fix(db): drop stale migration-90 grandfather entry 0090_pull_request_detail_sync_head_sha was renumbered to 0092; keep KNOWN_MIGRATION_DUPLICATES and the check-migrations success summary aligned with the real files on disk. Closes #8897 --- scripts/check-migrations.ts | 8 ++++---- src/db/migration-collisions.ts | 1 - test/unit/check-migrations-script.test.ts | 2 +- test/unit/migration-collisions.test.ts | 11 +++++++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/scripts/check-migrations.ts b/scripts/check-migrations.ts index daf29d84db..eade600e4a 100644 --- a/scripts/check-migrations.ts +++ b/scripts/check-migrations.ts @@ -23,12 +23,12 @@ // • 0074 — both 0074_ai_review_cache (#1462) and 0074_orb_self_enrollment_disabled (#1465, a bare ADD COLUMN) // merged + deployed before the collision surfaced; the column already exists in prod, so a rename would // re-run the ALTER and fail. Grandfathered for the same reason as 0015/0017. -// • 0090 — both 0090_contributor_cap_label (#2479) and 0090_pull_request_detail_sync_head_sha (#2527) -// merged with bare ADD COLUMN statements. Preserve both filenames so already-applied databases never -// replay either ALTER under a new migration name. +// • 0090 — historically both 0090_contributor_cap_label (#2479) and 0090_pull_request_detail_sync_head_sha +// (#2527) collided; the latter was renumbered to 0092, so only contributor_cap_label remains at 90 and +// the grandfather entry was removed (#8897). // • 0156 — both 0156_draft_pr_close_policy and 0156_pull_request_screenshot_table_presence_satisfied // merged independently from the same base and were both applied to production before the collision -// surfaced; bare ADD COLUMN statements, same grandfather reasoning as 0074/0090. +// surfaced; bare ADD COLUMN statements, same grandfather reasoning as 0074. import { readdirSync, readFileSync } from "node:fs"; import { detectMigrationCollisions, extractMigrationNumber, KNOWN_MIGRATION_DUPLICATES, MIGRATION_FILENAME_PATTERN } from "../src/db/migration-collisions.js"; import { detectColumnCollisions } from "../src/db/migration-column-extraction.js"; diff --git a/src/db/migration-collisions.ts b/src/db/migration-collisions.ts index 9be43179a3..968db407f3 100644 --- a/src/db/migration-collisions.ts +++ b/src/db/migration-collisions.ts @@ -26,7 +26,6 @@ export const KNOWN_MIGRATION_DUPLICATES: ReadonlyMap [15, new Set(["0015_github_agent_command_feedback.sql", "0015_product_usage_events.sql"])], [17, new Set(["0017_agent_recommendation_outcomes.sql", "0017_product_usage_role_retention_rollups.sql"])], [74, new Set(["0074_ai_review_cache.sql", "0074_orb_self_enrollment_disabled.sql"])], - [90, new Set(["0090_contributor_cap_label.sql", "0090_pull_request_detail_sync_head_sha.sql"])], [156, new Set(["0156_draft_pr_close_policy.sql", "0156_pull_request_screenshot_table_presence_satisfied.sql"])], ]); diff --git a/test/unit/check-migrations-script.test.ts b/test/unit/check-migrations-script.test.ts index 1b910458bb..356ae2adea 100644 --- a/test/unit/check-migrations-script.test.ts +++ b/test/unit/check-migrations-script.test.ts @@ -37,7 +37,7 @@ describe("check-migrations script", () => { it("reports every grandfathered duplicate migration number in the success summary", () => { const output = execFileSync(TSX_BIN, ["scripts/check-migrations.ts"], { encoding: "utf8" }); - expect(output).toContain("(5 grandfathered duplicates: 0015, 0017, 0074, 0090, 0156)"); + expect(output).toContain("(4 grandfathered duplicates: 0015, 0017, 0074, 0156)"); }); it.each([ diff --git a/test/unit/migration-collisions.test.ts b/test/unit/migration-collisions.test.ts index ea4fd1e810..2c9a6f42f3 100644 --- a/test/unit/migration-collisions.test.ts +++ b/test/unit/migration-collisions.test.ts @@ -75,10 +75,17 @@ describe("KNOWN_MIGRATION_DUPLICATES (#2550)", () => { it("stays byte-identical to scripts/check-migrations.ts's grandfathered list", () => { // A drift here would mean the CI script and the live premerge recheck disagree about what's grandfathered // — this pins the exact set so a future addition to one side without the other is caught immediately. - expect([...KNOWN_MIGRATION_DUPLICATES.keys()].sort((a, b) => a - b)).toEqual([15, 17, 74, 90, 156]); - expect(KNOWN_MIGRATION_DUPLICATES.get(90)).toEqual(new Set(["0090_contributor_cap_label.sql", "0090_pull_request_detail_sync_head_sha.sql"])); + expect([...KNOWN_MIGRATION_DUPLICATES.keys()].sort((a, b) => a - b)).toEqual([15, 17, 74, 156]); + expect(KNOWN_MIGRATION_DUPLICATES.has(90)).toBe(false); expect(KNOWN_MIGRATION_DUPLICATES.get(156)).toEqual( new Set(["0156_draft_pr_close_policy.sql", "0156_pull_request_screenshot_table_presence_satisfied.sql"]), ); }); + + it("does not report a collision for the single real migration 90 file (#8897)", () => { + // 0090_pull_request_detail_sync_head_sha.sql was renumbered to 0092; only contributor_cap_label remains at 90. + expect( + detectMigrationCollisions(["0090_contributor_cap_label.sql", "0092_pull_request_detail_sync_head_sha.sql"], KNOWN_MIGRATION_DUPLICATES), + ).toEqual([]); + }); });