1
0
Fork 0
mirror of synced 2024-07-07 15:25:52 +12:00

Fix tests after merge.

This commit is contained in:
Sam Rose 2023-10-23 09:49:57 +01:00
parent a563cf3594
commit 2d26597d07
No known key found for this signature in database
3 changed files with 14 additions and 4 deletions

View file

@ -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,
}

View file

@ -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()

View file

@ -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) {