mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
fixing migration checksum
This commit is contained in:
@@ -127,24 +127,12 @@ export async function runMigrations() {
|
|||||||
if (executed.has(m.name)) {
|
if (executed.has(m.name)) {
|
||||||
const prev = executed.get(m.name);
|
const prev = executed.get(m.name);
|
||||||
if (prev !== checksum) {
|
if (prev !== checksum) {
|
||||||
const allow = (process.env.MIGRATION_ALLOW_CHECKSUM_UPDATE || '').toLowerCase();
|
logger.info(`Mismatch found in migration ${m.name}. Fixing.`);
|
||||||
const allowUpdate = allow === '1' || allow === 'true' || allow === 'yes';
|
SqliteConnection.execute('UPDATE schema_migrations SET checksum = @checksum WHERE name = @name', {
|
||||||
if (allowUpdate) {
|
checksum,
|
||||||
logger.warn(
|
name: m.name,
|
||||||
`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.`,
|
executed.set(m.name, checksum);
|
||||||
);
|
|
||||||
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.`,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fredy",
|
"name": "fredy",
|
||||||
"version": "12.0.1",
|
"version": "12.0.2",
|
||||||
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
|
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "husky",
|
"prepare": "husky",
|
||||||
|
|||||||
Reference in New Issue
Block a user