2022-01-24 11:48:59 +01:00
|
|
|
const {
|
|
|
|
MIGRATION_TYPES,
|
|
|
|
runMigrations,
|
|
|
|
} = require("@budibase/backend-core/migrations")
|
|
|
|
|
|
|
|
// migration functions
|
|
|
|
import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
|
|
|
import * as quota1 from "./functions/quotas1"
|
2022-01-27 11:40:31 +01:00
|
|
|
import * as appUrls from "./functions/appUrls"
|
2022-03-16 09:18:09 +01:00
|
|
|
import * as developerQuota from "./functions/developerQuota"
|
|
|
|
import * as publishedAppsQuota from "./functions/publishedAppsQuota"
|
2022-01-24 11:48:59 +01:00
|
|
|
|
|
|
|
export interface Migration {
|
|
|
|
type: string
|
|
|
|
name: string
|
2022-01-27 11:40:31 +01:00
|
|
|
opts?: object
|
2022-01-24 11:48:59 +01:00
|
|
|
fn: Function
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* e.g.
|
|
|
|
* {
|
|
|
|
* tenantIds: ['bb'],
|
|
|
|
* force: {
|
|
|
|
* global: ['quota_1']
|
|
|
|
* }
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
export interface MigrationOptions {
|
|
|
|
tenantIds?: string[]
|
2022-03-08 15:21:41 +01:00
|
|
|
force?: {
|
2022-01-24 11:48:59 +01:00
|
|
|
[type: string]: string[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-27 11:40:31 +01:00
|
|
|
export const MIGRATIONS: Migration[] = [
|
2022-01-24 11:48:59 +01:00
|
|
|
{
|
|
|
|
type: MIGRATION_TYPES.GLOBAL,
|
|
|
|
name: "user_email_view_casing",
|
|
|
|
fn: userEmailViewCasing.run,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: MIGRATION_TYPES.GLOBAL,
|
|
|
|
name: "quotas_1",
|
|
|
|
fn: quota1.run,
|
|
|
|
},
|
2022-01-27 11:40:31 +01:00
|
|
|
{
|
|
|
|
type: MIGRATION_TYPES.APP,
|
|
|
|
name: "app_urls",
|
|
|
|
opts: { all: true },
|
|
|
|
fn: appUrls.run,
|
|
|
|
},
|
2022-03-04 14:42:50 +01:00
|
|
|
{
|
|
|
|
type: MIGRATION_TYPES.GLOBAL,
|
2022-03-16 09:18:09 +01:00
|
|
|
name: "developer_quota",
|
|
|
|
fn: developerQuota.run,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: MIGRATION_TYPES.GLOBAL,
|
|
|
|
name: "published_apps_quota",
|
|
|
|
fn: publishedAppsQuota.run,
|
2022-03-04 14:42:50 +01:00
|
|
|
},
|
2022-01-24 11:48:59 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
export const migrate = async (options?: MigrationOptions) => {
|
2022-03-29 17:03:44 +02:00
|
|
|
await runMigrations(MIGRATIONS, options)
|
2022-01-24 11:48:59 +01:00
|
|
|
}
|