Fix tests after merge.
This commit is contained in:
parent
a563cf3594
commit
2d26597d07
|
@ -2,10 +2,12 @@ import { populateExternalTableSchemas } from "./validation"
|
|||
import * as getters from "./getters"
|
||||
import * as updates from "./update"
|
||||
import * as utils from "./utils"
|
||||
import { migrate } from "./migration"
|
||||
|
||||
export default {
|
||||
populateExternalTableSchemas,
|
||||
...updates,
|
||||
...getters,
|
||||
...utils,
|
||||
migrate,
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ export async function migrate(
|
|||
let migrator = getColumnMigrator(table, oldColumn, newColumn)
|
||||
let oldTable = cloneDeep(table)
|
||||
|
||||
table = await sdk.tables.addColumn(table, newColumn)
|
||||
table.schema[newColumn.name] = newColumn
|
||||
table = await sdk.tables.saveTable(table)
|
||||
|
||||
await migrator.doMigration()
|
||||
|
||||
|
|
|
@ -3,21 +3,28 @@ import { isExternalTable } from "../../../integrations/utils"
|
|||
import sdk from "../../index"
|
||||
import { context } from "@budibase/backend-core"
|
||||
import { isExternal } from "./utils"
|
||||
import { DocumentInsertResponse } from "@budibase/nano"
|
||||
|
||||
import * as external from "./external"
|
||||
import * as internal from "./internal"
|
||||
import { cloneDeep } from "lodash"
|
||||
export * as external from "./external"
|
||||
export * as internal from "./internal"
|
||||
|
||||
export async function saveTable(table: Table) {
|
||||
export async function saveTable(table: Table): Promise<Table> {
|
||||
const db = context.getAppDB()
|
||||
let resp: DocumentInsertResponse
|
||||
if (isExternalTable(table._id!)) {
|
||||
const datasource = await sdk.datasources.get(table.sourceId!)
|
||||
datasource.entities![table.name] = table
|
||||
await db.put(datasource)
|
||||
resp = await db.put(datasource)
|
||||
} else {
|
||||
await db.put(table)
|
||||
resp = await db.put(table)
|
||||
}
|
||||
|
||||
let tableClone = cloneDeep(table)
|
||||
tableClone._rev = resp.rev
|
||||
return tableClone
|
||||
}
|
||||
|
||||
export async function update(table: Table, renaming?: RenameColumn) {
|
||||
|
|
Loading…
Reference in New Issue