Add header
This commit is contained in:
parent
05b5692520
commit
34d3edc2db
|
@ -28,6 +28,7 @@ export enum Header {
|
|||
CSRF_TOKEN = "x-csrf-token",
|
||||
CORRELATION_ID = "x-budibase-correlation-id",
|
||||
AUTHORIZATION = "authorization",
|
||||
MIGRATING_APP = "x-budibase-migrating-app",
|
||||
}
|
||||
|
||||
export enum GlobalRole {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
import queue from "./queue"
|
||||
import { Next } from "koa"
|
||||
import { getAppMigrationVersion } from "./appMigrationMetadata"
|
||||
import { MIGRATIONS } from "./migrations"
|
||||
import { UserCtx } from "@budibase/types"
|
||||
import { Header } from "@budibase/backend-core"
|
||||
|
||||
export * from "./appMigrationMetadata"
|
||||
|
||||
|
@ -15,7 +18,11 @@ export const latestMigration = MIGRATIONS.map(m => m.id)
|
|||
|
||||
const getTimestamp = (versionId: string) => versionId?.split("_")[0]
|
||||
|
||||
export async function checkMissingMigrations(appId: string) {
|
||||
export async function checkMissingMigrations(
|
||||
ctx: UserCtx,
|
||||
next: Next,
|
||||
appId: string
|
||||
) {
|
||||
const currentVersion = await getAppMigrationVersion(appId)
|
||||
|
||||
if (getTimestamp(currentVersion) < getTimestamp(latestMigration)) {
|
||||
|
@ -29,5 +36,9 @@ export async function checkMissingMigrations(appId: string) {
|
|||
removeOnFail: true,
|
||||
}
|
||||
)
|
||||
|
||||
ctx.response.set(Header.MIGRATING_APP, appId)
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -8,7 +8,5 @@ export default async (ctx: UserCtx, next: any) => {
|
|||
return next()
|
||||
}
|
||||
|
||||
await checkMissingMigrations(appId)
|
||||
|
||||
return next()
|
||||
return checkMissingMigrations(ctx, next, appId)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue