ministryofjustice / Claim-for-Crown-Court-Defence

Claim for Crown Court Defence, formerly Advocate Defence Payments (ADP), aka Crime Billing Online (CBO)
MIT License
25 stars 7 forks source link

Delete S3 files for old reports #2443

Closed lostie closed 2 years ago

lostie commented 6 years ago

As part of the existent process to delete old records: https://github.com/ministryofjustice/Claim-for-Crown-Court-Defence/blob/51e9880c1afaf632cb37750f2787926a897d91d1/app/models/stats/stats_report.rb#L38-L41

ensure the associated S3 files (if they exists are also removed).

jsugarman commented 3 years ago

@jrmhaig does the activestorage migration deal with this issue

mpw5 commented 2 years ago

Reviewing old issues: ActiveStorage handles purging of attachments for deleted reports: before_destroy -> { document.purge }.

Tested in dev:

Stats::StatsReport.last.id = 1156 Stats::StatsReport.last.document.id = 285 Stats::StatsReport.clean_up("submitted_claims") Stats::StatsReport.find(1156) = Couldn't find Stats::StatsReport with 'id'=1156 ActiveStorage::Attachment.find(285) = "Couldn't find ActiveStorage::Attachment with 'id'=285"