Moving SQS table functionality into SDK, accessible to migrations.

This commit is contained in:
mike12345567 2024-04-09 10:43:26 +01:00
parent ef46afe530
commit c820114054
3 changed files with 10 additions and 5 deletions

View File

@ -16,7 +16,6 @@ import viewTemplate from "../view/viewBuilder"
import { cloneDeep } from "lodash/fp"
import { quotas } from "@budibase/pro"
import { events, context } from "@budibase/backend-core"
import { addTableToSqlite } from "./sqlite"
import {
AutoFieldSubType,
ContextUser,
@ -34,6 +33,8 @@ import {
FieldTypeSubtypes,
AttachmentFieldMetadata,
} from "@budibase/types"
import sdk from "../../../sdk"
import env from "../../../environment"
export async function clearColumns(table: Table, columnNames: string[]) {
const db = context.getAppDB()
@ -343,7 +344,9 @@ class TableSaveFunctions {
importRows: this.importRows,
user: this.user,
})
await addTableToSqlite(table)
if (env.SQS_SEARCH_ENABLE) {
await sdk.tables.sqs.addTableToSqlite(table)
}
return table
}

View File

@ -3,6 +3,7 @@ import * as getters from "./getters"
import * as updates from "./update"
import * as utils from "./utils"
import { migrate } from "./migration"
import * as sqs from "./internal/sqs"
export default {
populateExternalTableSchemas,
@ -10,4 +11,5 @@ export default {
...getters,
...utils,
migrate,
sqs,
}

View File

@ -1,8 +1,8 @@
import { context, SQLITE_DESIGN_DOC_ID } from "@budibase/backend-core"
import { FieldType, SQLiteDefinition, SQLiteType, Table } from "@budibase/types"
import { cloneDeep } from "lodash"
import sdk from "../../../sdk"
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../db/utils"
import tablesSdk from "../"
import { CONSTANT_INTERNAL_ROW_COLS } from "../../../../db/utils"
const BASIC_SQLITE_DOC: SQLiteDefinition = {
_id: SQLITE_DESIGN_DOC_ID,
@ -53,7 +53,7 @@ function mapTable(table: Table): { [key: string]: SQLiteType } {
// nothing exists, need to iterate though existing tables
async function buildBaseDefinition(): Promise<SQLiteDefinition> {
const tables = await sdk.tables.getAllInternalTables()
const tables = await tablesSdk.getAllInternalTables()
const definition = cloneDeep(BASIC_SQLITE_DOC)
for (let table of tables) {
definition.sql.tables[table._id!] = {