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, soUploadrecords are orphaned. - Because
ExportUploadare 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
How to set up and validate locally
- Count the number of existing records:
Upload.count&BulkImports::ExportUpload.count - Create a group with a project in it.
- Export the group into a new destination using Direct Transfer.
- Count the records again and observe the resulting files in object storage.
- Delete the group.
- 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