Changing how latest migration is determined.
This commit is contained in:
parent
e86eb7082d
commit
a4e646fc64
|
@ -15,18 +15,15 @@ export type AppMigration = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getLatestEnabledMigrationId(migrations?: AppMigration[]) {
|
export function getLatestEnabledMigrationId(migrations?: AppMigration[]) {
|
||||||
const enabledMigrations: AppMigration[] = []
|
let latestMigrationId: string | undefined
|
||||||
for (let migration of migrations || MIGRATIONS) {
|
for (let migration of migrations || MIGRATIONS) {
|
||||||
// if a migration is disabled, all migrations after it are disabled
|
// if a migration is disabled, all migrations after it are disabled
|
||||||
if (migration.disabled) {
|
if (migration.disabled) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
enabledMigrations.push(migration)
|
latestMigrationId = migration.id
|
||||||
}
|
}
|
||||||
return enabledMigrations
|
return latestMigrationId
|
||||||
.map(m => m.id)
|
|
||||||
.sort()
|
|
||||||
.reverse()[0]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTimestamp(versionId: string) {
|
function getTimestamp(versionId: string) {
|
||||||
|
@ -41,7 +38,10 @@ export async function checkMissingMigrations(
|
||||||
const currentVersion = await getAppMigrationVersion(appId)
|
const currentVersion = await getAppMigrationVersion(appId)
|
||||||
const latestMigration = getLatestEnabledMigrationId()
|
const latestMigration = getLatestEnabledMigrationId()
|
||||||
|
|
||||||
if (getTimestamp(currentVersion) < getTimestamp(latestMigration)) {
|
if (
|
||||||
|
latestMigration &&
|
||||||
|
getTimestamp(currentVersion) < getTimestamp(latestMigration)
|
||||||
|
) {
|
||||||
await queue.add(
|
await queue.add(
|
||||||
{
|
{
|
||||||
appId,
|
appId,
|
||||||
|
|
Loading…
Reference in New Issue