app id fixes
This commit is contained in:
parent
7f26a60cc9
commit
4f34e1b2c7
|
@ -18,6 +18,7 @@ import {
|
||||||
UserCreatedEvent,
|
UserCreatedEvent,
|
||||||
RoleAssignedEvent,
|
RoleAssignedEvent,
|
||||||
UserPermissionAssignedEvent,
|
UserPermissionAssignedEvent,
|
||||||
|
AppCreatedEvent,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import * as context from "../context"
|
import * as context from "../context"
|
||||||
import { CacheKeys } from "../cache/generic"
|
import { CacheKeys } from "../cache/generic"
|
||||||
|
@ -130,7 +131,7 @@ const CUSTOM_PROPERTY_SUFFIX: any = {
|
||||||
[Event.VIEW_FILTER_CREATED]: (properties: ViewFilterCreatedEvent) => {
|
[Event.VIEW_FILTER_CREATED]: (properties: ViewFilterCreatedEvent) => {
|
||||||
return properties.tableId // best uniqueness
|
return properties.tableId // best uniqueness
|
||||||
},
|
},
|
||||||
[Event.APP_PUBLISHED]: (properties: AppPublishedEvent) => {
|
[Event.APP_CREATED]: (properties: AppCreatedEvent) => {
|
||||||
return properties.appId // best uniqueness
|
return properties.appId // best uniqueness
|
||||||
},
|
},
|
||||||
[Event.APP_PUBLISHED]: (properties: AppPublishedEvent) => {
|
[Event.APP_PUBLISHED]: (properties: AppPublishedEvent) => {
|
||||||
|
|
|
@ -9,6 +9,7 @@ const {
|
||||||
getGlobalDBName,
|
getGlobalDBName,
|
||||||
getTenantId,
|
getTenantId,
|
||||||
} = require("../tenancy")
|
} = require("../tenancy")
|
||||||
|
const context = require("../context")
|
||||||
|
|
||||||
exports.MIGRATION_TYPES = {
|
exports.MIGRATION_TYPES = {
|
||||||
GLOBAL: "global", // run once per tenant, recorded in global db, global db is provided as an argument
|
GLOBAL: "global", // run once per tenant, recorded in global db, global db is provided as an argument
|
||||||
|
@ -90,7 +91,14 @@ exports.runMigration = async (migration, options = {}) => {
|
||||||
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
|
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
|
||||||
)
|
)
|
||||||
// run the migration with tenant context
|
// run the migration with tenant context
|
||||||
await migration.fn(db)
|
if (migrationType === exports.MIGRATION_TYPES.APP) {
|
||||||
|
await context.doInAppContext(db.name, async () => {
|
||||||
|
await migration.fn(db)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
await migration.fn(db)
|
||||||
|
}
|
||||||
|
|
||||||
log(
|
log(
|
||||||
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Complete`
|
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Complete`
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue