diff --git a/packages/twenty-server/src/engine/core-modules/application/application.service.ts b/packages/twenty-server/src/engine/core-modules/application/application.service.ts index 6e67d8b63ec..9d738347fd8 100644 --- a/packages/twenty-server/src/engine/core-modules/application/application.service.ts +++ b/packages/twenty-server/src/engine/core-modules/application/application.service.ts @@ -452,6 +452,13 @@ export class ApplicationService { ); } + // Nullify file FK references before deleting files to avoid + // RESTRICT constraint violation (application references file via packageJsonFileId/yarnLockFileId) + await this.applicationRepository.update( + { universalIdentifier, workspaceId }, + { packageJsonFileId: null, yarnLockFileId: null }, + ); + await this.fileStorageService.deleteApplicationFiles({ workspaceId, applicationUniversalIdentifier: universalIdentifier,