{"record":{"id":"599f738a018cabd8","repo":"twentyhq/twenty","slug":"failed-to-delete-message-direction-field-for-works","errorCode":null,"errorMessage":"Failed to delete message.direction field for workspace ${workspaceId}","messagePattern":"Failed to delete message\\.direction field for workspace (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/twenty-server/src/database/commands/upgrade-version-command/2-3/2-3-workspace-command-1777400000000-drop-message-direction-field.command.ts","lineNumber":95,"sourceCode":"          allFlatEntityOperationByMetadataName: {\n            fieldMetadata: {\n              flatEntityToCreate: [],\n              flatEntityToDelete: [directionFieldMetadata],\n              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 message.direction field:\\n${JSON.stringify(validateAndBuildResult, null, 2)}`,\n      );\n\n      throw new Error(\n        `Failed to delete message.direction field for workspace ${workspaceId}`,\n      );\n    }\n\n    this.logger.log(\n      `Deleted message.direction field for workspace ${workspaceId}`,\n    );\n  }\n}\n","sourceCodeStart":77,"sourceCodeEnd":105,"githubUrl":"https://github.com/twentyhq/twenty/blob/1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6/packages/twenty-server/src/database/commands/upgrade-version-command/2-3/2-3-workspace-command-1777400000000-drop-message-direction-field.command.ts#L77-L105","documentation":"Thrown by the 2.3 command that drops the message.direction field. It submits a field-metadata delete operation through validateBuildAndRunLegacyWorkspaceMigration; on status === 'fail' it logs the report and throws. The report shows why the field deletion could not be built/applied.","triggerScenarios":"The message.direction field is referenced by a view, view-field, or relation that still exists (cascade delete blocked); the field's column cannot be dropped because a constraint/index depends on it; the field universalIdentifier no longer resolves because it was already removed in a prior run.","commonSituations":"A prior interrupted 2.3 run deleted the metadata but not the dependent view/relation; a custom view built on message.direction prevents the drop; DB-level index/constraint left over from an old schema.","solutions":["Read the logged JSON report to identify the blocking dependency (view/view-field/relation).","Remove or update the dependent view/relation rows for message.direction, then re-run.","If the field is already gone at metadata level, mark the workspace as upgraded for this command and clear any orphaned column manually."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before running, confirm no view/view-field still references message.direction:\nconst dependents = Object.values(flatViewFieldMaps.byId).filter(vf => vf.fieldMetadataUniversalIdentifier === MESSAGE_DIRECTION_UI);\nif (dependents.length > 0) { /* drop or reassign them first */ }","typeGuard":null,"tryCatchPattern":"try {\n  await command.runOnWorkspace({ workspaceId, options });\n} catch (e) {\n  logger.error({ workspaceId, err: e.message }, 'message.direction drop failed');\n}","preventionTips":["Remove dependent views/relations on a field before its drop command runs.","On partial failure, clear orphaned columns/indices manually before retrying."],"tags":["migration","upgrade-command","validate-and-build","workspace","field-metadata","message","drop-field"],"backgroundTag":null,"analyzedSha":"1f5dd2bbd2a8da3419c8cfd52dd545c0024df1a6","analyzedAt":"2026-08-12T15:37:27.593Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}