Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
feat: add schema support for orphanedRowAction
Browse files Browse the repository at this point in the history
Adds support for setting the action for orphaned relation rows when using separate entity definitions

Fixes typeorm#7417
  • Loading branch information
Jamieson Baker committed May 6, 2021
1 parent 9470e15 commit 8bc51f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/entity-schema/EntitySchemaRelationOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@ export interface EntitySchemaRelationOptions {
*/
deferrable?: DeferrableType;

/**
* When a child row is removed from its parent, determines if the child row should be orphaned (default) or deleted.
*/
orphanedRowAction?: "nullify" | "delete";
}
3 changes: 2 additions & 1 deletion src/entity-schema/EntitySchemaTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ export class EntitySchemaTransformer {
onUpdate: relationSchema.onUpdate,
deferrable: relationSchema.deferrable,
primary: relationSchema.primary,
persistence: relationSchema.persistence
persistence: relationSchema.persistence,
orphanedRowAction: relationSchema.orphanedRowAction
}
};

Expand Down

0 comments on commit 8bc51f2

Please sign in to comment.