diff --git a/packages/twenty-server/src/database/commands/upgrade-version/0-24/0-24-set-custom-object-is-soft-deletable.command.ts b/packages/twenty-server/src/database/commands/upgrade-version/0-24/0-24-set-custom-object-is-soft-deletable.command.ts index 0d745a96ed14..3f3cecdcc128 100644 --- a/packages/twenty-server/src/database/commands/upgrade-version/0-24/0-24-set-custom-object-is-soft-deletable.command.ts +++ b/packages/twenty-server/src/database/commands/upgrade-version/0-24/0-24-set-custom-object-is-soft-deletable.command.ts @@ -150,17 +150,19 @@ export class SetCustomObjectIsSoftDeletableCommand extends ActiveWorkspacesComma }) satisfies Partial, ); - if (newDeletedAtFields.length > 0) { - const createdDeletedAtFields = - await this.fieldMetadataRepository.insert(newDeletedAtFields); - - this.logger.log( - `Created ${createdDeletedAtFields.identifiers.length} deletedAt fields for workspace ${workspaceId}`, - ); - } else { + if (newDeletedAtFields.length === 0) { this.logger.log( `No new deletedAt fields needed for workspace ${workspaceId}`, ); + + return; } + + const createdDeletedAtFields = + await this.fieldMetadataRepository.insert(newDeletedAtFields); + + this.logger.log( + `Created ${createdDeletedAtFields.identifiers.length} deletedAt fields for workspace ${workspaceId}`, + ); } }