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

Commit 8bc51f2

Browse files
author
Jamieson Baker
committed
feat: add schema support for orphanedRowAction
Adds support for setting the action for orphaned relation rows when using separate entity definitions Fixes typeorm#7417
1 parent 9470e15 commit 8bc51f2

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/entity-schema/EntitySchemaRelationOptions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@ export interface EntitySchemaRelationOptions {
9898
*/
9999
deferrable?: DeferrableType;
100100

101+
/**
102+
* When a child row is removed from its parent, determines if the child row should be orphaned (default) or deleted.
103+
*/
104+
orphanedRowAction?: "nullify" | "delete";
101105
}

src/entity-schema/EntitySchemaTransformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ export class EntitySchemaTransformer {
136136
onUpdate: relationSchema.onUpdate,
137137
deferrable: relationSchema.deferrable,
138138
primary: relationSchema.primary,
139-
persistence: relationSchema.persistence
139+
persistence: relationSchema.persistence,
140+
orphanedRowAction: relationSchema.orphanedRowAction
140141
}
141142
};
142143

0 commit comments

Comments
 (0)