Dont run migration again when rc

This commit is contained in:
Owen
2026-06-01 13:58:04 -07:00
parent 09b2671759
commit c6a52ffc75
2 changed files with 42 additions and 2 deletions

View File

@@ -128,7 +128,7 @@ async function executeScripts() {
console.log(`Starting migrations from version ${startVersion}`); console.log(`Starting migrations from version ${startVersion}`);
const migrationsToRun = migrations.filter((migration) => const migrationsToRun = migrations.filter((migration) =>
semver.gt(migration.version, startVersion) shouldRunMigration(migration.version, startVersion)
); );
console.log( console.log(
@@ -179,3 +179,23 @@ async function executeScripts() {
throw error; throw error;
} }
} }
function shouldRunMigration(migrationVersion: string, currentVersion: string) {
const migration = semver.parse(migrationVersion);
const current = semver.parse(currentVersion);
// Treat x.y.z-rc.* as equivalent to x.y.z so restarts on RC builds do not re-run the same migration.
if (
migration &&
current &&
migration.prerelease.length === 0 &&
current.prerelease[0] === "rc" &&
migration.major === current.major &&
migration.minor === current.minor &&
migration.patch === current.patch
) {
return false;
}
return semver.gt(migrationVersion, currentVersion);
}

View File

@@ -169,7 +169,7 @@ async function executeScripts() {
console.log(`Starting migrations from version ${startVersion}`); console.log(`Starting migrations from version ${startVersion}`);
const migrationsToRun = migrations.filter((migration) => const migrationsToRun = migrations.filter((migration) =>
semver.gt(migration.version, startVersion) shouldRunMigration(migration.version, startVersion)
); );
console.log( console.log(
@@ -223,3 +223,23 @@ async function executeScripts() {
throw error; throw error;
} }
} }
function shouldRunMigration(migrationVersion: string, currentVersion: string) {
const migration = semver.parse(migrationVersion);
const current = semver.parse(currentVersion);
// Treat x.y.z-rc.* as equivalent to x.y.z so restarts on RC builds do not re-run the same migration.
if (
migration &&
current &&
migration.prerelease.length === 0 &&
current.prerelease[0] === "rc" &&
migration.major === current.major &&
migration.minor === current.minor &&
migration.patch === current.patch
) {
return false;
}
return semver.gt(migrationVersion, currentVersion);
}