{"record":{"id":"4fe1b07150e53d68","repo":"twentyhq/twenty","slug":"failed-to-delete-calendarevent-recordingpreference","errorCode":null,"errorMessage":"Failed to delete CalendarEvent recordingPreference field for workspace ${workspaceId}","messagePattern":"Failed to delete CalendarEvent recordingPreference field for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000066000-drop-calendar-event-recording-preference.command.ts","lineNumber":100,"sourceCode":"              flatEntityToUpdate: [],\n            },\n          },\n          workspaceId,\n          applicationUniversalIdentifier:\n            twentyStandardFlatApplication.universalIdentifier,\n        },\n      );\n\n    if (validateAndBuildResult.status === 'fail') {\n      this.logger.error(\n        `Failed to delete CalendarEvent recordingPreference field:\\n${JSON.stringify(\n          validateAndBuildResult,\n          null,\n          2,\n        )}`,\n      );\n\n      throw new Error(\n        `Failed to delete CalendarEvent recordingPreference field for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Deleted CalendarEvent recordingPreference field for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":82,"sourceCodeEnd":110,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-14/2-14-workspace-command-1799000066000-drop-calendar-event-recording-preference.command.ts#L82-L110","documentation":"Thrown by the 2.14 command that drops the CalendarEvent.recordingPreference field when validateBuildAndRunLegacyWorkspaceMigration returns status 'fail' for the delete operation. The logger.error line above it prints the full validation result; the thrown error is workspace-scoped. A delete can fail validation when the field is referenced by other metadata (views, layouts, computed fields) that the validator refuses to leave dangling.","triggerScenarios":"Running the 2.14 upgrade on a workspace where recordingPreference is still referenced by a viewField, pageLayout, or relation that the build phase cannot cascade-delete; or where the field was already partially removed leaving orphaned references.","commonSituations":"Custom objects/views built on top of recordingPreference; a prior failed run that deleted the view-field but not the fieldMetadata; metadata drift from manual DB edits.","solutions":["Read the logger.error output immediately preceding the throw to see which references block the delete.","Remove or repoint the dependent viewField/pageLayout rows referencing recordingPreference, then re-run.","Verify the recordingPreference field still exists and is active before this command (the delete payload is built upstream); if already gone, the command should be a no-op.","Re-run the workspace upgrade after cleanup."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm recordingPreference has no remaining references that would block delete.\nconst refs = await dataSource.query(`\n  SELECT 'viewField' AS src, id FROM core.\"viewField\" WHERE \"fieldMetadataId\" = $1\n  UNION ALL\n  SELECT 'pageLayoutField', id FROM core.\"pageLayoutField\" WHERE \"fieldMetadataId\" = $1\n`, [fieldId]);\nif (refs.length) throw new Error(`recordingPreference still referenced: ${JSON.stringify(refs)}`);","typeGuard":"function isFailResult(r: unknown): r is { status: 'fail' } {\n  return typeof r === 'object' && r !== null && (r as any).status === 'fail';\n}","tryCatchPattern":"try {\n  const res = await service.validateBuildAndRunLegacyWorkspaceMigration(payload);\n  if (res.status === 'fail') throw new Error(`Failed to delete ... for workspace ${workspaceId}`);\n} catch (err) { upgradeAudit.record(workspaceId, command.id, err); throw err; }","preventionTips":["Cascade or repoint viewField/pageLayout references before deleting a standard field.","Detect half-completed prior runs and clean up dangling references before re-running."],"tags":["migration","workspace-upgrade","metadata-validation","calendar-event"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}