1
0
Fork 0
mirror of synced 2024-08-05 05:11:43 +12:00

Changing how latest migration is determined.

This commit is contained in:
mike12345567 2024-06-06 17:26:37 +01:00
parent e86eb7082d
commit a4e646fc64

View file

@ -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,