mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-02-16 17:51:55 +00:00
fix(note-user-permission): ensure whole row gets deleted
By default, TypeORM wants to NULL the child-side of a many-to-one relation, when the relation gets deleted. This is not possible when the column is not nullable, so the whole row needs to get deleted. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
264013430e
commit
3e096e9cbe
1 changed files with 2 additions and 0 deletions
|
@ -20,12 +20,14 @@ export class NoteUserPermission {
|
|||
@ManyToOne((_) => User, {
|
||||
primary: true,
|
||||
onDelete: 'CASCADE', // This deletes the NoteUserPermission, when the associated Note is deleted
|
||||
orphanedRowAction: 'delete', // This ensures the whole row is deleted when the Permission stops being referenced
|
||||
})
|
||||
user: User;
|
||||
|
||||
@ManyToOne((_) => Note, (note) => note.userPermissions, {
|
||||
primary: true,
|
||||
onDelete: 'CASCADE', // This deletes the NoteUserPermission, when the associated Note is deleted
|
||||
orphanedRowAction: 'delete', // This ensures the whole row is deleted when the Permission stops being referenced
|
||||
})
|
||||
note: Note;
|
||||
|
||||
|
|
Loading…
Reference in a new issue