twenty
twenty copied to clipboard
[Flexible-Schema] Add an onCascade property to relation decorators
Scope & Context
Currently, all relations have "ON CASCADE DELETE" by default. This causes some issues for certain objects. Ideally we would like to define this individually for each FK. For example, deleting a Favorite row when the associated entity has been deleted is a good thing to delegate to the DB. However we don't want to delete a person if a company has been deleted because a person can be re-attached to another company.
We could have something like this (taking typeorm implementation as an example)
@RelationMetadata({
type: RelationMetadataType.ONE_TO_MANY,
objectName: 'messageChannel',
onDelete: 'CASCADE'
})
Technical inputs
TBD