diff --git a/server/models/Collection.js b/server/models/Collection.js index 6b1b3d75bb..de86526e0c 100644 --- a/server/models/Collection.js +++ b/server/models/Collection.js @@ -197,28 +197,16 @@ Collection.associate = (models) => { }; Collection.addHook("afterDestroy", async (model: Collection) => { - // sets deletedAt attribute of archived, templates and normal documents + // sets deletedAt attribute of templates and normal documents await Document.destroy({ where: { collectionId: model.id, + archivedAt: { + [Op.eq]: null, + }, }, }); - // updating the documents that moved to deleted state from archived state - await Document.update( - { - archivedAt: null, - }, - { - where: { - deletedAt: { - [Op.ne]: null, - }, - }, - paranoid: false, - } - ); - // updating the drafts to have no collection await Document.unscoped().update( {