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), }), ); }