Adding a migration for the plugin quotas to make sure they are always accurate in self host at startup.
This commit is contained in:
parent
b9154fe096
commit
b20db4d22a
|
@ -33,4 +33,8 @@ export const DEFINITIONS: MigrationDefinition[] = [
|
||||||
type: MigrationType.GLOBAL,
|
type: MigrationType.GLOBAL,
|
||||||
name: MigrationName.GLOBAL_INFO_SYNC_USERS,
|
name: MigrationName.GLOBAL_INFO_SYNC_USERS,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: MigrationType.GLOBAL,
|
||||||
|
name: MigrationName.PLUGIN_COUNT,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { tenancy, logging } from "@budibase/backend-core"
|
||||||
|
import { plugins } from "@budibase/pro"
|
||||||
|
import env from "../../environment"
|
||||||
|
|
||||||
|
export const run = async () => {
|
||||||
|
// only a self hosted op
|
||||||
|
if (!env.SELF_HOSTED) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await tenancy.doInTenant(tenancy.DEFAULT_TENANT_ID, async () => {
|
||||||
|
await plugins.checkPluginQuotas()
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logging.logAlert("Failed to update plugin quotas", err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
||||||
import * as quota1 from "./functions/quotas1"
|
import * as quota1 from "./functions/quotas1"
|
||||||
import * as appUrls from "./functions/appUrls"
|
import * as appUrls from "./functions/appUrls"
|
||||||
import * as backfill from "./functions/backfill"
|
import * as backfill from "./functions/backfill"
|
||||||
|
import * as pluginCount from "./functions/pluginCount"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populate the migration function and additional configuration from
|
* Populate the migration function and additional configuration from
|
||||||
|
@ -68,6 +69,14 @@ export const buildMigrations = () => {
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
case MigrationName.PLUGIN_COUNT: {
|
||||||
|
serverMigrations.push({
|
||||||
|
...definition,
|
||||||
|
fn: pluginCount.run,
|
||||||
|
silent: !!env.SELF_HOSTED,
|
||||||
|
preventRetry: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ export enum MigrationName {
|
||||||
EVENT_INSTALLATION_BACKFILL = "event_installation_backfill",
|
EVENT_INSTALLATION_BACKFILL = "event_installation_backfill",
|
||||||
GLOBAL_INFO_SYNC_USERS = "global_info_sync_users",
|
GLOBAL_INFO_SYNC_USERS = "global_info_sync_users",
|
||||||
PLATFORM_USERS_EMAIL_CASING = "platform_users_email_casing",
|
PLATFORM_USERS_EMAIL_CASING = "platform_users_email_casing",
|
||||||
|
PLUGIN_COUNT = "plugin_count",
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MigrationDefinition {
|
export interface MigrationDefinition {
|
||||||
|
|
Loading…
Reference in New Issue