Merge pull request #14860 from Budibase/BUDI-8774/delete-row-actions-when-unfetching-tables

Remove row actions when unfetching tables
This commit is contained in:
Adria Navarro 2024-10-24 18:05:07 +02:00 committed by GitHub
commit c13613f75c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import * as datasources from "./datasources"
import tableSdk from "../tables" import tableSdk from "../tables"
import { getIntegration } from "../../../integrations" import { getIntegration } from "../../../integrations"
import { context } from "@budibase/backend-core" import { context } from "@budibase/backend-core"
import sdk from "../.."
function checkForSchemaErrors(schema: Record<string, Table>) { function checkForSchemaErrors(schema: Record<string, Table>) {
const errors: Record<string, string> = {} const errors: Record<string, string> = {}
@ -96,6 +97,15 @@ export async function buildSchemaFromSource(
const datasource = await datasources.get(datasourceId) const datasource = await datasources.get(datasourceId)
const { tables, errors } = await buildFilteredSchema(datasource, tablesFilter) const { tables, errors } = await buildFilteredSchema(datasource, tablesFilter)
const oldTables = datasource.entities || {}
const tablesToRemove = Object.keys(oldTables).filter(
t => !Object.keys(tables).includes(t)
)
for (const table of tablesToRemove) {
await sdk.rowActions.deleteAll(oldTables[table]._id!)
}
datasource.entities = tables datasource.entities = tables
datasources.setDefaultDisplayColumns(datasource) datasources.setDefaultDisplayColumns(datasource)