From e45b920b0b404f410c7e898578564f2d5ea47d2a Mon Sep 17 00:00:00 2001 From: mintaka Date: Mon, 12 Oct 2026 16:43:44 -0400 Subject: [PATCH] ci(sql-migration-gate): re-enable migration-immutability after the 0001 collapse (RIG-4897) The 0001 collapse suspended the append-only migration check so open migration PRs could fold into 0001_init.sql before the dev database was wiped. The wipe is done and those PRs have merged or are landing, so the gate entrypoint calls checkMigrationImmutability again instead of returning a hardcoded pass for that check. A new test spawns the real gate entrypoint against a fixture repo with an edited base migration and expects exit 1 naming the file, so a future suspension at the call site fails the suite instead of passing silently. Co-authored-by: Matt Wilkinson --- tools/sql-migration-gate/index.test.ts | 20 ++++++++++++++++++++ tools/sql-migration-gate/index.ts | 9 +-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/tools/sql-migration-gate/index.test.ts b/tools/sql-migration-gate/index.test.ts index dad5e9dd1..956afe8f2 100644 --- a/tools/sql-migration-gate/index.test.ts +++ b/tools/sql-migration-gate/index.test.ts @@ -580,6 +580,26 @@ console.log(JSON.stringify(await checkMigrationImmutability(${JSON.stringify(roo rmSync(root, { recursive: true, force: true }); } }); + + test("the gate entrypoint fails on an edited base migration", async () => { + const path = "go/internal/store/migrations/0001_init.sql"; + await withRepo({ [path]: "SELECT 1;\n" }, async (root) => { + writeFileSync(join(root, path), "SELECT 2;\n"); + const child = Bun.spawn( + [process.execPath, join(import.meta.dir, "index.ts")], + { + cwd: root, + env: { ...process.env, GATE_ROOT: root, GATE_BASE_REF: "base" }, + stdout: "pipe", + stderr: "pipe", + }, + ); + const stderr = await new Response(child.stderr).text(); + expect(await child.exited, stderr).toBe(1); + expect(stderr).toContain(path); + expect(stderr).toContain("FAIL — findings from migration-immutability"); + }); + }); }); // --------------------------------------------------------------------------- diff --git a/tools/sql-migration-gate/index.ts b/tools/sql-migration-gate/index.ts index 0da85d614..afbcade9c 100644 --- a/tools/sql-migration-gate/index.ts +++ b/tools/sql-migration-gate/index.ts @@ -396,14 +396,7 @@ if (import.meta.main) { runLinter: makeSpawnLinter(root), log: (msg) => console.log(msg), err: (msg) => console.error(msg), - // Suspended while open migration PRs fold into 0001_init.sql; restore - // `checkMigrationImmutability(root)` once the dev DB is wiped. - runMigrationCheck: async () => ({ - name: "migration-immutability", - code: 0, - output: - "sql-migration-gate: migration-immutability suspended for the 0001 collapse", - }), + runMigrationCheck: () => checkMigrationImmutability(root), }), ); }