Prune exports with a service

What does this MR do and why?

When a group or project is deleted, database-level ON DELETE CASCADE then removes all records in the hierarchy down to and including BulkImports::ExportUpload.

Bypassing Rails here has an unintended consequence:

  • There is no FK relation between ExportUpload, so Upload records are orphaned.
  • Because ExportUpload are deleted at the DB level, the associated files never get deleted.

This MR ensures that Rails callbacks are executed when the project or group is removed.

References

#542228

How to set up and validate locally

  1. Count the number of existing records: Upload.count & BulkImports::ExportUpload.count
  2. Create a group with a project in it.
  3. Export the group into a new destination using Direct Transfer.
  4. Count the records again and observe the resulting files in object storage.
  5. Delete the group.
  6. Re-count the records and observe that the files should now be removed from object storage.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by James Nutt

Merge request reports

Loading