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:
@ -355,7 +355,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
});
|
||||
|
||||
if (fieldMetadata.type === FieldMetadataType.RELATION) {
|
||||
const isManyToManyRelation =
|
||||
const isManyToOneRelation =
|
||||
(fieldMetadata as FieldMetadataEntity<FieldMetadataType.RELATION>)
|
||||
.settings?.relationType === RelationType.MANY_TO_ONE;
|
||||
|
||||
@ -385,7 +385,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.DROP,
|
||||
columnName: isManyToManyRelation
|
||||
columnName: isManyToOneRelation
|
||||
? `${(fieldMetadata as FieldMetadataEntity<FieldMetadataType.RELATION>).settings?.joinColumnName}`
|
||||
: `${(targetFieldMetadata as FieldMetadataEntity<FieldMetadataType.RELATION>).settings?.joinColumnName}`,
|
||||
} satisfies WorkspaceMigrationColumnDrop,
|
||||
|
||||
Reference in New Issue
Block a user