From 408ab7ae1dfa5d1c7dedb2f9fde239596520b2e6 Mon Sep 17 00:00:00 2001 From: Sheogorath Date: Fri, 25 May 2018 14:54:00 +0200 Subject: Use cascaded deletes When we delete a user we should delete all the notes that belong to this user including the revisions of these notes. Signed-off-by: Sheogorath --- lib/models/note.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/models/note.js') diff --git a/lib/models/note.js b/lib/models/note.js index 7b9a909a..7d8e9625 100644 --- a/lib/models/note.js +++ b/lib/models/note.js @@ -91,7 +91,9 @@ module.exports = function (sequelize, DataTypes) { Note.belongsTo(models.User, { foreignKey: 'ownerId', as: 'owner', - constraints: false + constraints: false, + onDelete: 'CASCADE', + hooks: true }) Note.belongsTo(models.User, { foreignKey: 'lastchangeuserId', -- cgit v1.2.3