Delete related objects when deleting a review request.

Review Request #13735 — Created April 16, 2024 and submitted — Latest diff uploaded

Information

Review Board
release-7.x

Reviewers

We never really designed Review Board to delete data, and we (at least
I) also didn't fully understand how foreign keys and deletion worked
when we first designed many aspects of our database schema. The result
of this is that when a review request was deleted, we'd leave a bunch of
related things in the database, now completely orphaned. The biggest
offender here was file attachments, which not only use up space in the
database, but can also use up a lot of space on the filesystem.

This change adds a new signal handler for pre_delete on
ReviewRequest. In this handler, we explicitly delete change
descriptions, file attachments (both active and inactive), screenshots
(both active and inactive), and the diffset history.

A future change will add a management command to clean up any existing
orphaned objects.

  • Ran unit tests.
  • Individually disabled lines in the signal handler and verified that
    without this, we were leaving these objects in the DB, and with it,
    they get deleted.

Diff Revision 1 (Latest)

Commits

First Last Summary ID Author
Delete related objects when deleting a review request.
We never really designed Review Board to delete data, and we (at least I) also didn't fully understand how foreign keys and deletion worked when we first designed many aspects of our database schema. The result of this is that when a review request was deleted, we'd leave a bunch of related things in the database, now completely orphaned. The biggest offender here was file attachments, which not only use up space in the database, but can also use up a lot of space on the filesystem. This change adds a new signal handler for `pre_delete` on `ReviewRequest`. In this handler, we explicitly delete change descriptions, file attachments (both active and inactive), screenshots (both active and inactive), and the diffset history. A future change will add a management command to clean up any existing orphaned objects. Testing Done: - Ran unit tests. - Individually disabled lines in the signal handler and verified that without this, we were leaving these objects in the DB, and with it, they get deleted.
b528d0f1f78ec9c045d9378be3dda83d7e03ef10 David Trowbridge
reviewboard/reviews/signal_handlers.py
reviewboard/reviews/tests/test_signal_handlers.py
Loading...