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

Updating app migration to use a slightly different mechanism to allow disabling the migration pipeline.

This commit is contained in:
mike12345567 2024-06-05 16:57:16 +01:00
parent 4f6076d2ba
commit 80ddadbe06
3 changed files with 15 additions and 9 deletions

View file

@ -10,8 +10,14 @@ export * from "./appMigrationMetadata"
export type AppMigration = {
id: string
func: () => Promise<void>
// disabled so that by default all migrations listed are enabled
disabled?: boolean
}
// all migrations must be enabled for migrations to run
export const migrationsEnabled = (): boolean =>
MIGRATIONS.find(m => m.disabled) == null
export const getLatestMigrationId = () =>
MIGRATIONS.map(m => m.id)
.sort()

View file

@ -6,12 +6,10 @@ import { AppMigration } from "."
import m20240604153647_initial_sqs from "./migrations/20240604153647_initial_sqs"
// Migrations will be executed sorted by ID
export const MIGRATIONS: AppMigration[] = []
// only run the SQS migration if SQS is enabled
if (env.SQS_SEARCH_ENABLE) {
MIGRATIONS.push({
export const MIGRATIONS: AppMigration[] = [
{
id: "20240604153647_initial_sqs",
func: m20240604153647_initial_sqs,
})
}
disabled: !env.SQS_SEARCH_ENABLE,
},
]

View file

@ -1,11 +1,13 @@
import { UserCtx } from "@budibase/types"
import { checkMissingMigrations } from "../appMigrations"
import { checkMissingMigrations, migrationsEnabled } from "../appMigrations"
import { env } from "@budibase/backend-core"
export default async (ctx: UserCtx, next: any) => {
const { appId } = ctx
if (env.SKIP_APP_MIGRATIONS) {
// migrations can be disabled via environment variable, or can be disabled
// due to some of the migrations not being ready to run - disables all migrations
if (env.SKIP_APP_MIGRATIONS || !migrationsEnabled()) {
return next()
}