Don't use `sdk.tables.getTables` (as it fails randomly)

This commit is contained in:
Adria Navarro 2024-09-03 11:00:15 +02:00
parent e61b619740
commit e364bf5d65
1 changed files with 3 additions and 6 deletions

View File

@ -254,21 +254,18 @@ export function syncSchema(
} }
export async function renameLinkedViews(table: Table, renaming: RenameColumn) { export async function renameLinkedViews(table: Table, renaming: RenameColumn) {
const relatedTableIds = new Set<string>() const relatedTables: Record<string, Table> = {}
for (const field of Object.values(table.schema)) { for (const field of Object.values(table.schema)) {
if (field.type !== FieldType.LINK) { if (field.type !== FieldType.LINK) {
continue continue
} }
relatedTableIds.add(field.tableId) relatedTables[field.tableId] ??= await sdk.tables.getTable(field.tableId)
break break
} }
const relatedTables = await sdk.tables.getTables( for (const relatedTable of Object.values(relatedTables)) {
Array.from(relatedTableIds.values())
)
for (const relatedTable of relatedTables) {
let toSave = false let toSave = false
const viewsV2 = Object.values(relatedTable.views || {}).filter( const viewsV2 = Object.values(relatedTable.views || {}).filter(
sdk.views.isV2 sdk.views.isV2