-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Purge forms and associated resources #431
Conversation
777f320
to
6ebeb28
Compare
6ebeb28
to
777f61c
Compare
lib/model/migrations/20211027-01-add-purgeddAt-details-to-actees.js
Outdated
Show resolved
Hide resolved
777f61c
to
bb3258b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interactive review with @issa-tseng
const up = async (db) => { | ||
await db.schema.table('form_defs', (t) => { | ||
t.dropForeign('formId'); | ||
t.foreign('formId').references('forms.id').onDelete('cascade'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
look into doing these with an alter instead of a drop if possible
lib/model/query/forms.js
Outdated
const del = (form) => ({ run, Assignments }) => | ||
Promise.all([ run(markDeleted(form)), Assignments.revokeByActeeId(form.acteeId) ]); | ||
const del = (form) => ({ run, Assignments, Forms }) => | ||
Promise.all([ run(markDeleted(form)), Assignments.revokeByActeeId(form.acteeId) ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider just purging and not having to check it and mark deleted first
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to revoke by actee id still even if form purged without being deleted first
and ${_trashedFilter(force, id)}`) | ||
.then(() => run(sql` | ||
insert into audits ("action", "acteeId", "loggedAt") | ||
select 'form.purge', "acteeId", clock_timestamp() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
form.purge verb? maybe doesn't need to be in any verb table, but i'll double check
// 5. Purge unattached blobs | ||
const purge = (force = false, id = null) => ({ run, all, Blobs }) => | ||
run(sql` | ||
update audits set notes = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
take a stab at combining all these into a single quere
// 3. by a specific form id if deletedAt is also set (again for testing or potential future scenarios) | ||
|
||
const DAY_RANGE = 30; | ||
const _trashedFilter = (force, id) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@issa-tseng's going to look up some resource injection stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more notes from talking to @matthew-white
lib/model/migrations/20211027-01-add-purgeddAt-details-to-actees.js
Outdated
Show resolved
Hide resolved
lib/model/query/forms.js
Outdated
const del = (form) => ({ run, Assignments }) => | ||
Promise.all([ run(markDeleted(form)), Assignments.revokeByActeeId(form.acteeId) ]); | ||
const del = (form) => ({ run, Assignments, Forms }) => | ||
Promise.all([ run(markDeleted(form)), Assignments.revokeByActeeId(form.acteeId) ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might need to revoke by actee id still even if form purged without being deleted first
81eb8d5
to
8b32340
Compare
Rename actees deletedAt to purgedAt
rename opendatakit to getodk in migration
tests cleanup More form purge submission tests more tests: purging client audits tests about purging old/newly deleted forms
384fbd5
to
61ef815
Compare
This PR enables the purging of soft-deleted forms and their associated resources (definitions, versions, submissions, attachments, comments, etc.)
Purging follows these steps:
As a side effect of deleting/purging Forms, we needed to address issue getodk/central#127 and decide what to display in the audit log for deleted resources. To do this, we added
purgedAt
,purgedName
,details
toActees
to capture information about a permanently removed resources and then exposed this info via the audit log API.This PR has a number of high-impact migrations:
actees
tablePurging is done through a task and command line script that will be called via cron job in the main Central repo. The script will be called daily to purge forms deleted over 30 days prior, but can also be used to purge a specific form by its numeric id.