Skip to content

Commit

Permalink
fix(document): cannot delete old documents with children
Browse files Browse the repository at this point in the history
  • Loading branch information
vmarseguerra committed Oct 23, 2024
1 parent a3f0070 commit b840b76
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions api/controllers/v1/document/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down

0 comments on commit b840b76

Please sign in to comment.