test(db): opt issuer migration checks into issuer identity

This commit is contained in:
Gustavo Valverde
2026-08-24 13:09:07 -04:00
parent c27bcfadde
commit 5b5a49bcd2
@@ -580,7 +580,10 @@ describe("get-migration: unsafe schema changes on populated tables", () => {
*/
it("refuses to add the account issuer column to a populated account table, pointing at the upgrade guide", async () => {
const failure = await captureFailure(
getMigrations({ database: createAccountDb({}) }),
getMigrations({
account: { identityStrategy: "issuer" },
database: createAccountDb({}),
}),
);
expect(failure).toBeInstanceOf(BetterAuthError);
@@ -594,7 +597,10 @@ describe("get-migration: unsafe schema changes on populated tables", () => {
const failure = await captureFailure(
getMigrations({
database: createAccountDb({ issuerColumn: "identity_issuer" }),
account: { fields: { issuer: "identity_issuer" } },
account: {
identityStrategy: "issuer",
fields: { issuer: "identity_issuer" },
},
}),
);
@@ -606,6 +612,7 @@ describe("get-migration: unsafe schema changes on populated tables", () => {
it("plans a required column without a default when the table is empty", async () => {
const { compileMigrations, toBeAdded } = await getMigrations({
account: { identityStrategy: "issuer" },
database: createAccountDb({ seeded: false }),
});
@@ -704,6 +711,7 @@ describe("get-migration: nullable columns for required fields", () => {
it("accepts a required field whose live column is not null", async () => {
const { compileMigrations, toBeAdded } = await getMigrations({
account: { identityStrategy: "issuer" },
database: createAccountDb({ issuer: "notNull" }),
});
@@ -717,6 +725,7 @@ describe("get-migration: nullable columns for required fields", () => {
const warnings: string[] = [];
await getMigrations({
account: { identityStrategy: "issuer" },
database: createAccountDb({ issuer: "nullable" }),
logger: warnLogger(warnings),
});
@@ -772,7 +781,10 @@ describe("get-migration: nullable columns for required fields", () => {
describe("get-migration: inspecting a migration that cannot be applied", () => {
it("reports the unsafe column change and still compiles the statements", async () => {
const { compileMigrations, unsafeChanges } = await getMigrations(
{ database: createAccountDb({}) },
{
account: { identityStrategy: "issuer" },
database: createAccountDb({}),
},
{ throwOnUnsafe: false },
);