Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tools/sql-migration-gate/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
});

// ---------------------------------------------------------------------------
Expand Down
9 changes: 1 addition & 8 deletions tools/sql-migration-gate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}),
);
}
Loading