Fixes app re-install on workspaces that have already received the v2.5
`NormalizeCompositeFieldDefaultsCommand` backfill: those workspaces now
have non-null `defaultValue` on every composite system field (createdBy,
updatedBy, position, searchVector, …). The next `installApplication` →
`synchronizeFromManifest(isSystemBuild: false)` rebuilds the diff and
hits `FIELD_MUTATION_NOT_ALLOWED` on each row because the manifest TO
state never declared system fields, so the dispatcher saw them as
FROM-only and emitted bad delete/update actions.
## Root cause
`computeApplicationManifestAllUniversalFlatEntityMaps` walks
`manifest.objects[].fields` and never scaffolds the eight standard
system fields the runtime actually attaches on object creation
(`buildDefaultFlatFieldMetadatasForCustomObject`). On top of that,
the scaffolder seeded each system field's `universalIdentifier` with
`v4()`, so even if we wanted to mirror them on the TO side from the
manifest converter, the random UIDs would never line up with the rows
already in the workspace.
## Fix (three pieces)
1. **Switch `buildDefaultFlatFieldMetadatasForCustomObject` from `v4` to
`v5`.** Same pattern as `NAVIGATION_COMMAND_UUID_NAMESPACE`: every
system field's universalIdentifier is derived deterministically from
`${objectMetadataUniversalIdentifier}/${name}` against a new
`SYSTEM_FIELD_UUID_NAMESPACE`. Exported as
`computeSystemFieldUniversalIdentifier` so the manifest converter
and the upgrade migration both compute identical UUIDs.
2. **Inject the eight system fields into manifest TO.** Inside
`computeApplicationManifestAllUniversalFlatEntityMaps`, after each
`flatObjectMetadata` is added, call
`buildDefaultFlatFieldMetadatasForCustomObject({ skipNameField: true })`
and merge its eight rows into `flatFieldMetadataMaps`. Apps that
explicitly declare a field with one of the system names (e.g. an
`id: TEXT` regression) are left untouched so the existing
`validateObjectMetadataSystemFieldsIntegrity` validator still
surfaces the mistake.
3. **2-5 workspace upgrade migration:**
`2-5-workspace-command-1798600000000-refactor-system-field-universal-identifiers.command.ts`
rewrites every existing `isSystem: true` field whose name is one of
the eight standard names to the new v5 identifier (direct
`UPDATE core."fieldMetadata"` on the `universalIdentifier` column —
no FK references it, all DB joins are on the per-workspace `id`
PK), then invalidates the `flatFieldMetadataMaps` and
`flatObjectMetadataMaps` cache entries. Direct analogue of
`1-21-workspace-command-1775500013000-refactor-navigation-commands`.
After (1)+(2)+(3) ship, the dispatcher computes an empty diff for
system fields on app re-installs: TO and FROM contain the same eight
rows with the same v5 universalIdentifiers and the same scaffolder
defaults. The validator path is never hit.
## CI
`sync-application-system-fields-auto-attached.integration-spec.ts`
exercises three scenarios that would have caught this regression:
- First sync of an app whose object declares zero system fields ends
with the eight rows present and v5-addressed.
- Re-syncing the identical manifest is a no-op.
- A re-sync after a manually-cleared `defaultValue` on `createdBy`
(the exact post-2.5-backfill shape) succeeds — this is the case
that failed on prod after PR #20581 / the rolling 2.5 upgrade.
The existing dev-sync vitest suite never exercised
`installApplication` directly because the LOCAL sourceType short-
circuits the install handler, so the bug stayed silent until the CD
pipeline hit it on the registry-install path.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The #1 Open-Source CRM
Website ·
Documentation ·
Roadmap ·
Discord ·
Figma
Why Twenty
Twenty gives technical teams the building blocks for a custom CRM that meets complex business needs and quickly adapts as the business evolves. Twenty is the CRM you build, ship, and version like the rest of your stack.
Learn more about why we built Twenty
Installation
Cloud
The fastest way to get started. Sign up at twenty.com and spin up a workspace in under a minute, with no infrastructure to manage and always up to date.
Build an app
Scaffold a new app with the Twenty CLI:
npx create-twenty-app my-app
Define objects, fields, and views as code:
import { defineObject, FieldType } from 'twenty-sdk/define';
export default defineObject({
nameSingular: 'deal',
namePlural: 'deals',
labelSingular: 'Deal',
labelPlural: 'Deals',
fields: [
{ name: 'name', label: 'Name', type: FieldType.TEXT },
{ name: 'amount', label: 'Amount', type: FieldType.CURRENCY },
{ name: 'closeDate', label: 'Close Date', type: FieldType.DATE_TIME },
],
});
Then ship it to your workspace:
npx twenty deploy
See the app development guide for objects, views, agents, and logic functions.
Self-hosting
Run Twenty on your own infrastructure with Docker Compose, or contribute locally via the local setup guide.
Everything you need
Twenty gives you the building blocks of a modern CRM (objects, views, workflows, and agents) and lets you extend them as code. Here's a tour of what's in the box.
Want to go deeper? Read the User Guide for product walkthroughs, or the
Documentation for developer reference.
|
|
|
|
|
|
Stack
TypeScript
Nx
NestJS, with BullMQ,
PostgreSQL,
Redis
React, with Jotai, Linaria and Lingui
Thanks
Thanks to these amazing services that we use and recommend for UI testing (Chromatic), code review (Greptile), catching bugs (Sentry) and translating (Crowdin).
Join the Community
Star the repo ·
Discord ·
Feature requests ·
Releases ·
X ·
LinkedIn ·
Crowdin ·
Contribute





