diff --git a/api/controllers/v1/document/delete.js b/api/controllers/v1/document/delete.js index 57177148e..8764682ad 100644 --- a/api/controllers/v1/document/delete.js +++ b/api/controllers/v1/document/delete.js @@ -56,15 +56,20 @@ module.exports = async (req, res) => { if (deletePermanently) { await TDocument.update({ redirectTo: documentId }).set({ + dateReviewed: new Date(), // Avoid a uniqueness error redirectTo: shouldMergeInto ? mergeIntoId : null, }); - await TDocument.update({ parent: documentId }).set({ - parent: shouldMergeInto ? mergeIntoId : null, - }); + await TDocument.update({ parent: documentId }) + .set({ + dateReviewed: new Date(), // Avoid a uniqueness error + parent: shouldMergeInto ? mergeIntoId : null, + }) + .meta({ fetch: false }); await HDocument.update({ parent: documentId }).set({ parent: shouldMergeInto ? mergeIntoId : null, }); - await TDocument.update({ authorizationDocument: null }).set({ + await TDocument.update({ authorizationDocument: documentId }).set({ + dateReviewed: new Date(), // Avoid a uniqueness error authorizationDocument: null, });