Add a management command to clean up orphaned data.

Review Request #13740 — Created April 17, 2024 and submitted — Latest diff uploaded

Information

Review Board
release-7.x

Reviewers

This change adds a new management command that will clean up various
pieces of data in the database and filesystem that could have been left
behind if administrators used the "Delete Permanently" action on a
review request or deleted review requests via the admin UI.

It will query each of the affected items to get a total count, and then
perform the actual deletion in batches. This allows us to show nice
progress bars, as well as make the command interruptible.

Populated my database with a bunch of data including screenshots,
file attachments, diffs, and change descriptions. Temporarily disabled
our new signal handler and deleted the review requests.

  • Ran with --show-counts-only and saw the expected counts for each type
    of object.
  • Ran normally and watched it delete all the objects.
  • Ran again with --show-counts-only and saw that it no longer reported
    any orphaned data.
  • Set the batch size low and verified that the progress bars worked
    correctly.
  • Built and looked at the docs.

Diff Revision 4 (Latest)

orig
1
2
3
4

Commits

First Last Summary ID Author
Add a management command to clean up orphaned data.
This change adds a new management command that will clean up various pieces of data in the database and filesystem that could have been left behind if administrators used the "Delete Permanently" action on a review request or deleted review requests via the admin UI. It will query each of the affected items to get a total count, and then perform the actual deletion in batches. This allows us to show nice progress bars, as well as make the command interruptible. Testing Done: - Populated my database with a bunch of data including screenshots, file attachments, diffs, and change descriptions. Temporarily disabled our new signal handler and deleted the review requests. Ran with --show-counts-only and saw the expected counts for each type of object. Ran normally and watched it delete all the objects. Ran again with --show-counts-only and saw that it no longer reported any orphaned data. - Set the batch size low and verified that the progress bars worked correctly. - Built and looked at the docs.
e45b6c7f2d5c4d59c0c67d381f2cbf62dffef994 David Trowbridge
docs/manual/admin/sites/management-commands.rst
reviewboard/dependencies.py
reviewboard/reviews/management/commands/clean-orphaned-data.py
Loading...