Files
twenty/packages/twenty-server
martmull b49225df4b Reorder validation execution to match migration action order (#22200)
## Summary
Reorders the validation execution sequence in the workspace entity
migration builder to match the actual execution order of migration
actions (delete → create → update). This ensures that optimistic entity
maps accurately simulate the post-migration state during validation.

## Key Changes
- **Moved creation validation before update validation** in
`WorkspaceEntityMigrationBuilderService`: Creation validation now
executes immediately after deletion validation, allowing updates to
reference entities created in the same migration without validators
needing to peek into to-be-created maps.

- **Removed `remainingFlatEntityMapsToValidate` parameter from update
validation**: Since creation validation now completes before update
validation begins, the optimistic maps already contain all created
entities. Updates can safely reference newly created entities through
the optimistic maps without needing access to remaining-to-create maps.

- **Simplified `FlatNavigationMenuItemValidatorService`**: Removed the
logic that combined remaining-to-create maps with optimistic maps, now
relying solely on the optimistic maps which contain all previously
validated creations.

- **Updated type definition**: Modified `FlatEntityUpdateValidationArgs`
type to exclude `remainingFlatEntityMapsToValidate` since it's no longer
needed.

## Implementation Details
This change enables a more intuitive validation flow where:
1. Deletions are validated first
2. Creations are validated next (in topological order for
self-referential FKs)
3. Updates are validated last (can safely reference newly created
entities)

The optimistic maps are progressively built during creation validation,
so by the time update validation runs, they faithfully represent the
post-migration state, eliminating the need for validators to access
separate remaining-to-create maps.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/22200?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
2026-06-26 10:17:00 +02:00
..
2026-04-02 11:20:08 +00:00
2026-04-02 11:20:08 +00:00