fixing migration checksum

This commit is contained in:
orangecoding
2025-09-18 18:42:19 +02:00
parent 1d99fc95f7
commit 28e885f6c7
2 changed files with 7 additions and 19 deletions

View File

@@ -127,24 +127,12 @@ export async function runMigrations() {
if (executed.has(m.name)) {
const prev = executed.get(m.name);
if (prev !== checksum) {
const allow = (process.env.MIGRATION_ALLOW_CHECKSUM_UPDATE || '').toLowerCase();
const allowUpdate = allow === '1' || allow === 'true' || allow === 'yes';
if (allowUpdate) {
logger.warn(
`Checksum mismatch for already executed migration ${m.name}, but MIGRATION_ALLOW_CHECKSUM_UPDATE is enabled. ` +
`Updating recorded checksum and continuing without re-running the migration.`,
);
SqliteConnection.execute('UPDATE schema_migrations SET checksum = @checksum WHERE name = @name', {
checksum,
name: m.name,
});
executed.set(m.name, checksum);
} else {
throw new Error(
`Checksum mismatch for already executed migration ${m.name}. ` +
`Do not modify applied migrations. Create a new migration instead.`,
);
}
logger.info(`Mismatch found in migration ${m.name}. Fixing.`);
SqliteConnection.execute('UPDATE schema_migrations SET checksum = @checksum WHERE name = @name', {
checksum,
name: m.name,
});
executed.set(m.name, checksum);
}
continue;
}

View File

@@ -1,6 +1,6 @@
{
"name": "fredy",
"version": "12.0.1",
"version": "12.0.2",
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
"scripts": {
"prepare": "husky",