Browse Source

fix(core): Correctly cascade deletions in HistoryEntries

BREAKING CHANGE: Deletions of Orders or Customers now cascade to any associated HistoryEntries,
thus preserving referential integrity. This involves a DB schema change which will necessitate
a migration.
Michael Bromley 5 years ago
parent
commit
6054b7174b

+ 1 - 1
packages/core/src/entity/history-entry/customer-history-entry.entity.ts

@@ -11,6 +11,6 @@ export class CustomerHistoryEntry extends HistoryEntry {
         super(input);
     }
 
-    @ManyToOne((type) => Customer)
+    @ManyToOne(type => Customer, { onDelete: 'CASCADE' })
     customer: Customer;
 }

+ 1 - 1
packages/core/src/entity/history-entry/order-history-entry.entity.ts

@@ -11,6 +11,6 @@ export class OrderHistoryEntry extends HistoryEntry {
         super(input);
     }
 
-    @ManyToOne(type => Order)
+    @ManyToOne(type => Order, { onDelete: 'CASCADE' })
     order: Order;
 }