-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete and purge individual submissions (#1150)
* added soft-delete submission endpoint * added submission purge mechanism * More tests and redacting audit log details * Tests of deleted submissions not appearing in export * Use submission.delete verb * odata test and comment test refinement * deleted submissions with odata skip token * failing/skipped test for client audit purge bug * small changes * properly purge client audits of deleted forms and submissions * fix parameters * refactoring purge task and cli * Fixing how the cli script runs * restore soft-deleted submissions * updating migration dates and names * manually call blob purge in tests and add purge audit log tests * test for not deleting draft submissions * Small fixes * shared client audit blob test * more tests of reusing instance id * test of migration * purge task transaction * filter for non deleted subs/forms in an entity source query
- Loading branch information
Showing
17 changed files
with
1,430 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lib/model/migrations/20240914-01-add-submission-delete-verb.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
const up = (db) => db.raw(` | ||
UPDATE roles | ||
SET verbs = verbs || '["submission.delete", "submission.restore"]'::jsonb | ||
WHERE system in ('admin', 'manager') | ||
`); | ||
|
||
const down = (db) => db.raw(` | ||
UPDATE roles | ||
SET verbs = (verbs - 'submission.delete' - 'submission.restore') | ||
WHERE system in ('admin', 'manager') | ||
`); | ||
|
||
module.exports = { up, down }; | ||
|
27 changes: 27 additions & 0 deletions
27
lib/model/migrations/20240914-02-remove-orphaned-client-audits.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2024 ODK Central Developers | ||
// See the NOTICE file at the top-level directory of this distribution and at | ||
// https://github.com/getodk/central-backend/blob/master/NOTICE. | ||
// This file is part of ODK Central. It is subject to the license terms in | ||
// the LICENSE file found in the top-level directory of this distribution and at | ||
// https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central, | ||
// including this file, may be copied, modified, propagated, or distributed | ||
// except according to the terms contained in the LICENSE file. | ||
|
||
// From earlier form-purging, there could have been leftover client audits | ||
// that were not properly purged because of how they joined to submissions. | ||
// This migration deletes those client audit rows, allowing the blobs to finally | ||
// be de-referenced and also eventually purged (by the puring cron job). | ||
|
||
const up = (db) => db.raw(` | ||
DELETE FROM client_audits | ||
WHERE "blobId" NOT IN ( | ||
SELECT "blobId" FROM submission_attachments | ||
WHERE "blobId" IS NOT NULL | ||
AND "isClientAudit" IS true | ||
); | ||
`); | ||
|
||
const down = () => {}; | ||
|
||
module.exports = { up, down }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.