From 234c7feab2b117c4121c91773e3d3c567eecb0fb Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 3 Apr 2024 12:36:12 +0200 Subject: [PATCH] Remove single subtype from attachments --- .../server/src/api/controllers/table/utils.ts | 20 ------------------- packages/types/src/documents/app/row.ts | 4 ---- .../types/src/documents/app/table/schema.ts | 1 - 3 files changed, 25 deletions(-) diff --git a/packages/server/src/api/controllers/table/utils.ts b/packages/server/src/api/controllers/table/utils.ts index 0611a7ae0d..ac3a2a5c8a 100644 --- a/packages/server/src/api/controllers/table/utils.ts +++ b/packages/server/src/api/controllers/table/utils.ts @@ -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 } } diff --git a/packages/types/src/documents/app/row.ts b/packages/types/src/documents/app/row.ts index b17aececd7..222c346591 100644 --- a/packages/types/src/documents/app/row.ts +++ b/packages/types/src/documents/app/row.ts @@ -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, - }, } diff --git a/packages/types/src/documents/app/table/schema.ts b/packages/types/src/documents/app/table/schema.ts index 946df6836e..3eeeee0a81 100644 --- a/packages/types/src/documents/app/table/schema.ts +++ b/packages/types/src/documents/app/table/schema.ts @@ -115,7 +115,6 @@ export interface BBReferenceFieldMetadata export interface AttachmentFieldMetadata extends Omit { type: FieldType.ATTACHMENTS - subtype?: FieldSubtype.SINGLE } export interface FieldConstraints {