[local-sync] Don't delete messages via cascade when a folder is deleted

1. It could be expensive to delete many messages at the exact moment
   when the folder is deleted
2. The folder delete could actually just be a rename, and if we
   deleted all the messages, we would have to re-process them all
3. We already do a clean-up check for orphaned messages at the end
   of the sync loop, where we already know if the folder was
   actually deleted or just renamed
This commit is contained in:
Halla Moore 2017-01-10 10:08:58 -08:00
parent b03c0c9bc2
commit 1e6f7a6e6f

View file

@ -40,7 +40,7 @@ module.exports = (sequelize, Sequelize) => {
}, { }, {
classMethods: { classMethods: {
associate({Folder, Message, Thread}) { associate({Folder, Message, Thread}) {
Folder.hasMany(Message, {onDelete: 'cascade', hooks: true}) Folder.hasMany(Message)
Folder.belongsToMany(Thread, {through: 'thread_folders'}) Folder.belongsToMany(Thread, {through: 'thread_folders'})
}, },