Refactor new relation sync (#11711)

In this PR:
- this should fix the sync metadata for new relation system

This goes with the recent PR:
https://github.com/twentyhq/twenty/pull/11725

What we want:
- ONE_TO_MANY relations should have no joinColumn and no onDelete
- MANY_TO_ONE should have both
This commit is contained in:
Charles Bochet
2025-04-25 01:02:49 +02:00
committed by GitHub
parent 9fb7ef5d47
commit 0c8eb149e6
7 changed files with 285 additions and 156 deletions

View File

@ -129,8 +129,14 @@ export class MigrateRelationsToFieldMetadataCommand extends ActiveOrSuspendedWor
...fieldMetadata,
settings: {
relationType,
onDelete: relationMetadata.onDeleteAction,
joinColumnName: joinColumnFieldMetadata?.name,
onDelete:
relationType === RelationType.MANY_TO_ONE
? relationMetadata.onDeleteAction
: undefined,
joinColumnName:
relationType === RelationType.MANY_TO_ONE
? joinColumnFieldMetadata?.name
: undefined,
},
relationTargetFieldMetadataId,
relationTargetObjectMetadataId,