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/author.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/models/author.js') diff --git a/lib/models/author.js b/lib/models/author.js index 8b4f74e5..03f832a4 100644 --- a/lib/models/author.js +++ b/lib/models/author.js @@ -24,12 +24,16 @@ module.exports = function (sequelize, DataTypes) { Author.belongsTo(models.Note, { foreignKey: 'noteId', as: 'note', - constraints: false + constraints: false, + onDelete: 'CASCADE', + hooks: true }) Author.belongsTo(models.User, { foreignKey: 'userId', as: 'user', - constraints: false + constraints: false, + onDelete: 'CASCADE', + hooks: true }) } } -- cgit v1.2.3