mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
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 <sheogorath@shivering-isles.com>
This commit is contained in:
parent
8aa5c03213
commit
408ab7ae1d
3 changed files with 12 additions and 4 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -102,7 +102,9 @@ module.exports = function (sequelize, DataTypes) {
|
|||
Revision.belongsTo(models.Note, {
|
||||
foreignKey: 'noteId',
|
||||
as: 'note',
|
||||
constraints: false
|
||||
constraints: false,
|
||||
onDelete: 'CASCADE',
|
||||
hooks: true
|
||||
})
|
||||
},
|
||||
getNoteRevisions: function (note, callback) {
|
||||
|
|
Loading…
Reference in a new issue