1
0
Fork 0
mirror of synced 2024-07-03 13:30:46 +12:00

Remove single subtype from attachments

This commit is contained in:
Adria Navarro 2024-04-03 12:36:12 +02:00
parent 291ad618e3
commit 234c7feab2
3 changed files with 0 additions and 25 deletions

View file

@ -91,26 +91,6 @@ export async function checkForColumnUpdates(
await checkForViewUpdates(updatedTable, deletedColumns, columnRename)
}
const changedAttachmentSubtypeColumns = Object.values(
updatedTable.schema
).filter(
(column): column is AttachmentFieldMetadata =>
column.type === FieldType.ATTACHMENTS &&
column.subtype !== oldTable?.schema[column.name]?.subtype
)
for (const attachmentColumn of changedAttachmentSubtypeColumns) {
if (attachmentColumn.subtype === FieldTypeSubtypes.ATTACHMENTS.SINGLE) {
attachmentColumn.constraints ??= { length: {} }
attachmentColumn.constraints.length ??= {}
attachmentColumn.constraints.length.maximum = 1
attachmentColumn.constraints.length.message =
"cannot contain multiple files"
} else {
delete attachmentColumn.constraints?.length?.maximum
delete attachmentColumn.constraints?.length?.message
}
}
return { rows: updatedRows, table: updatedTable }
}

View file

@ -39,7 +39,6 @@ export interface Row extends Document {
export enum FieldSubtype {
USER = "user",
USERS = "users",
SINGLE = "single",
}
// The 'as' are required for typescript not to type the outputs as generic FieldSubtype
@ -48,7 +47,4 @@ export const FieldTypeSubtypes = {
USER: FieldSubtype.USER as FieldSubtype.USER,
USERS: FieldSubtype.USERS as FieldSubtype.USERS,
},
ATTACHMENTS: {
SINGLE: FieldSubtype.SINGLE as FieldSubtype.SINGLE,
},
}

View file

@ -115,7 +115,6 @@ export interface BBReferenceFieldMetadata
export interface AttachmentFieldMetadata
extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.ATTACHMENTS
subtype?: FieldSubtype.SINGLE
}
export interface FieldConstraints {