From a4e646fc64eae71ddff60c5043236a400b67ddbb Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 6 Jun 2024 17:26:37 +0100 Subject: [PATCH] Changing how latest migration is determined. --- packages/server/src/appMigrations/index.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/server/src/appMigrations/index.ts b/packages/server/src/appMigrations/index.ts index cac1e82716..8bd3ae7425 100644 --- a/packages/server/src/appMigrations/index.ts +++ b/packages/server/src/appMigrations/index.ts @@ -15,18 +15,15 @@ export type AppMigration = { } export function getLatestEnabledMigrationId(migrations?: AppMigration[]) { - const enabledMigrations: AppMigration[] = [] + let latestMigrationId: string | undefined for (let migration of migrations || MIGRATIONS) { // if a migration is disabled, all migrations after it are disabled if (migration.disabled) { break } - enabledMigrations.push(migration) + latestMigrationId = migration.id } - return enabledMigrations - .map(m => m.id) - .sort() - .reverse()[0] + return latestMigrationId } function getTimestamp(versionId: string) { @@ -41,7 +38,10 @@ export async function checkMissingMigrations( const currentVersion = await getAppMigrationVersion(appId) const latestMigration = getLatestEnabledMigrationId() - if (getTimestamp(currentVersion) < getTimestamp(latestMigration)) { + if ( + latestMigration && + getTimestamp(currentVersion) < getTimestamp(latestMigration) + ) { await queue.add( { appId,