Initalise migration version on creation
This commit is contained in:
parent
9625935a9b
commit
bd8c52094b
|
@ -52,6 +52,7 @@ import { BASE_LAYOUT_PROP_IDS } from "../../constants/layouts"
|
|||
import sdk from "../../sdk"
|
||||
import { builderSocket } from "../../websockets"
|
||||
import { sdk as sharedCoreSDK } from "@budibase/shared-core"
|
||||
import * as appMigrations from "../../appMigrations"
|
||||
|
||||
// utility function, need to do away with this
|
||||
async function getLayouts() {
|
||||
|
@ -334,6 +335,11 @@ async function performAppCreate(ctx: UserCtx) {
|
|||
/* istanbul ignore next */
|
||||
if (!env.isTest()) {
|
||||
await createApp(appId)
|
||||
// Initialise app migration version
|
||||
await appMigrations.updateAppMigrationMetadata({
|
||||
appId,
|
||||
version: appMigrations.latestMigration,
|
||||
})
|
||||
}
|
||||
|
||||
await cache.app.invalidateAppMetadata(appId, newApplication)
|
||||
|
|
|
@ -2,14 +2,18 @@ import queue from "./queue"
|
|||
import { getAppMigrationVersion } from "./appMigrationMetadata"
|
||||
import { MIGRATIONS } from "./migrations"
|
||||
|
||||
const latestMigration = MIGRATIONS.map(m => m.migrationId)
|
||||
export * from "./appMigrationMetadata"
|
||||
|
||||
export const latestMigration = MIGRATIONS.map(m => m.migrationId)
|
||||
.sort()
|
||||
.reverse()[0]
|
||||
|
||||
const getTimestamp = (versionId: string) => versionId.split("_")[0]
|
||||
|
||||
export async function checkMissingMigrations(appId: string) {
|
||||
const currentVersion = await getAppMigrationVersion(appId)
|
||||
|
||||
if (currentVersion < latestMigration) {
|
||||
if (getTimestamp(currentVersion) < getTimestamp(latestMigration)) {
|
||||
await queue.add(
|
||||
{
|
||||
appId,
|
||||
|
|
Loading…
Reference in New Issue