fix: skip comment-only migration SQL
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
createTableSql,
|
||||
parseMigration,
|
||||
applyMigrations,
|
||||
appliedMigrations,
|
||||
migrate,
|
||||
status,
|
||||
rollback,
|
||||
@@ -144,6 +145,22 @@ test("an empty migration set does not touch the database", async () => {
|
||||
expect(await applyMigrations(db, [])).toEqual([]);
|
||||
});
|
||||
|
||||
test("comment-only migrations are recorded without executing empty SQL", async () => {
|
||||
const db = createDb(sqlite());
|
||||
const migrations = [
|
||||
{
|
||||
name: "0001_placeholder",
|
||||
up: "-- Create application tables here.\n/* No schema yet. */\n;",
|
||||
down: "-- Nothing to roll back.",
|
||||
},
|
||||
];
|
||||
|
||||
expect(await applyMigrations(db, migrations)).toEqual(["0001_placeholder"]);
|
||||
expect(await appliedMigrations(db)).toEqual(["0001_placeholder"]);
|
||||
expect(await rollback(db, ".", { lock: false })).toBe("0001_placeholder");
|
||||
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