fix(forms): surface validation and recover schema drift
This commit is contained in:
@@ -161,6 +161,24 @@ test("comment-only migrations are recorded without executing empty SQL", async (
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test("add-column migrations recover when the column exists but the migration record does not", async () => {
|
||||
const db = createDb(sqlite());
|
||||
await db.exec("CREATE TABLE otp_challenges (id TEXT PRIMARY KEY, purpose TEXT NOT NULL)");
|
||||
const migrations = [
|
||||
{
|
||||
name: "0002_otp_purpose",
|
||||
up: "ALTER TABLE otp_challenges ADD COLUMN purpose TEXT NOT NULL DEFAULT 'verification';",
|
||||
down: "ALTER TABLE otp_challenges DROP COLUMN purpose;",
|
||||
},
|
||||
];
|
||||
|
||||
expect(await applyMigrations(db, migrations)).toEqual(["0002_otp_purpose"]);
|
||||
expect(await appliedMigrations(db)).toContain("0002_otp_purpose");
|
||||
const columns = await db.all<{ name: string }>("PRAGMA table_info(otp_challenges)");
|
||||
expect(columns.filter(({ name }) => name === "purpose")).toHaveLength(1);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test("migration dry-run plans changes without applying schema and honors cancellation", async () => {
|
||||
const db = createDb(sqlite());
|
||||
const migrations = [
|
||||
|
||||
Reference in New Issue
Block a user