Clean code
This commit is contained in:
parent
bc02fb372f
commit
a85d4460b1
|
@ -31,6 +31,7 @@ import {
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
FieldType,
|
FieldType,
|
||||||
FieldTypeSubtypes,
|
FieldTypeSubtypes,
|
||||||
|
AttachmentFieldMetadata,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export async function clearColumns(table: Table, columnNames: string[]) {
|
export async function clearColumns(table: Table, columnNames: string[]) {
|
||||||
|
@ -90,11 +91,14 @@ export async function checkForColumnUpdates(
|
||||||
await checkForViewUpdates(updatedTable, deletedColumns, columnRename)
|
await checkForViewUpdates(updatedTable, deletedColumns, columnRename)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const attachmentColumn of Object.values(updatedTable.schema).filter(
|
const changedAttachmentSubtypeColumns = Object.values(
|
||||||
column =>
|
updatedTable.schema
|
||||||
|
).filter(
|
||||||
|
(column): column is AttachmentFieldMetadata =>
|
||||||
column.type === FieldType.ATTACHMENT &&
|
column.type === FieldType.ATTACHMENT &&
|
||||||
column.subtype !== oldTable?.schema[column.name]?.subtype
|
column.subtype !== oldTable?.schema[column.name]?.subtype
|
||||||
)) {
|
)
|
||||||
|
for (const attachmentColumn of changedAttachmentSubtypeColumns) {
|
||||||
if (attachmentColumn.subtype === FieldTypeSubtypes.ATTACHMENT.SINGLE) {
|
if (attachmentColumn.subtype === FieldTypeSubtypes.ATTACHMENT.SINGLE) {
|
||||||
attachmentColumn.constraints ??= { length: {} }
|
attachmentColumn.constraints ??= { length: {} }
|
||||||
attachmentColumn.constraints.length ??= {}
|
attachmentColumn.constraints.length ??= {}
|
||||||
|
|
Loading…
Reference in New Issue