Force explicit deletion behavior for relations (#4775)
We've seen a few cascading errors (e.g. comment.activityId would be non nullable but cascade behavior is set to "set null"). I think it's safer if we have to explicitly chose the deletion behavior it every time. Especially since Postgres default to "No action" while we defaulted to "Set Null", which is confusing. In the future we will most likely introduce a second param `onSoftDelete` in the decorator
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
|
||||
import { RelationMetadataType } from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import {
|
||||
RelationMetadataType,
|
||||
RelationOnDeleteAction,
|
||||
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
|
||||
import { activityStandardFieldIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
|
||||
import { standardObjectIds } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
|
||||
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
|
||||
@ -91,6 +94,7 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => ActivityTargetObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
})
|
||||
@IsNullable()
|
||||
activityTargets: ActivityTargetObjectMetadata[];
|
||||
@ -105,6 +109,7 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => AttachmentObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.SET_NULL,
|
||||
})
|
||||
@IsNullable()
|
||||
attachments: AttachmentObjectMetadata[];
|
||||
@ -119,6 +124,7 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
@RelationMetadata({
|
||||
type: RelationMetadataType.ONE_TO_MANY,
|
||||
inverseSideTarget: () => CommentObjectMetadata,
|
||||
onDelete: RelationOnDeleteAction.CASCADE,
|
||||
})
|
||||
@IsNullable()
|
||||
comments: CommentObjectMetadata[];
|
||||
@ -131,6 +137,7 @@ export class ActivityObjectMetadata extends BaseObjectMetadata {
|
||||
icon: 'IconUserCircle',
|
||||
joinColumn: 'authorId',
|
||||
})
|
||||
@IsNullable()
|
||||
author: WorkspaceMemberObjectMetadata;
|
||||
|
||||
@FieldMetadata({
|
||||
|
||||
Reference in New Issue
Block a user