diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-20 20:22:56 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-09-20 20:22:56 +0200 |
commit | 576cbf5794b2e146892d7080b699882c2ba6ec6a (patch) | |
tree | ba0ee566a013053d90272126f2f5461ad6b1e30b /util/src/entities/User.ts | |
parent | :sparkles: finish and fix .delete() for one-to-many relations (diff) | |
download | server-576cbf5794b2e146892d7080b699882c2ba6ec6a.tar.xz |
:bug: fix .delete -> add onDelete: "CASCADE"
Diffstat (limited to 'util/src/entities/User.ts')
-rw-r--r-- | util/src/entities/User.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/src/entities/User.ts b/util/src/entities/User.ts index cef88777..4c86b2d8 100644 --- a/util/src/entities/User.ts +++ b/util/src/entities/User.ts @@ -127,11 +127,17 @@ export class User extends BaseClass { public_flags: number; @JoinColumn({ name: "relationship_ids" }) - @OneToMany(() => Relationship, (relationship: Relationship) => relationship.from) + @OneToMany(() => Relationship, (relationship: Relationship) => relationship.from, { + cascade: true, + orphanedRowAction: "delete", + }) relationships: Relationship[]; @JoinColumn({ name: "connected_account_ids" }) - @OneToMany(() => ConnectedAccount, (account: ConnectedAccount) => account.user) + @OneToMany(() => ConnectedAccount, (account: ConnectedAccount) => account.user, { + cascade: true, + orphanedRowAction: "delete", + }) connected_accounts: ConnectedAccount[]; @Column({ type: "simple-json", select: false }) |