Check if migrations are needed on app serve
This commit is contained in:
parent
8f9f33b6af
commit
d880302553
|
@ -25,8 +25,12 @@ import fs from "fs"
|
|||
import sdk from "../../../sdk"
|
||||
import * as pro from "@budibase/pro"
|
||||
import { App, Ctx, ProcessAttachmentResponse } from "@budibase/types"
|
||||
import {
|
||||
getAppMigrationVersion,
|
||||
getLatestMigrationId,
|
||||
} from "../../../appMigrations"
|
||||
|
||||
const send = require("koa-send")
|
||||
import send from "koa-send"
|
||||
|
||||
export const toggleBetaUiFeature = async function (ctx: Ctx) {
|
||||
const cookieName = `beta:${ctx.params.feature}`
|
||||
|
@ -125,7 +129,21 @@ export const deleteObjects = async function (ctx: Ctx) {
|
|||
)
|
||||
}
|
||||
|
||||
const requiresMigration = async (ctx: Ctx) => {
|
||||
const appId = context.getAppId()
|
||||
if (!appId) {
|
||||
ctx.throw("AppId could not be found")
|
||||
}
|
||||
|
||||
const latestAppliedMigration = await getAppMigrationVersion(appId)
|
||||
|
||||
const requiresMigrations = latestAppliedMigration !== getLatestMigrationId()
|
||||
return requiresMigrations
|
||||
}
|
||||
|
||||
export const serveApp = async function (ctx: Ctx) {
|
||||
const needMigrations = await requiresMigration(ctx)
|
||||
|
||||
const bbHeaderEmbed =
|
||||
ctx.request.get("x-budibase-embed")?.toLowerCase() === "true"
|
||||
|
||||
|
@ -273,7 +291,6 @@ export const getSignedUploadURL = async function (ctx: Ctx) {
|
|||
const { bucket, key } = ctx.request.body || {}
|
||||
if (!bucket || !key) {
|
||||
ctx.throw(400, "bucket and key values are required")
|
||||
return
|
||||
}
|
||||
try {
|
||||
const s3 = new AWS.S3({
|
||||
|
|
Loading…
Reference in New Issue