Migrate virus scans to blob metadata
This commit is contained in:
parent
6e8b9cf668
commit
d26f736f50
1 changed files with 22 additions and 0 deletions
22
lib/tasks/deployment/20190425102459_migrate_virus_scans.rake
Normal file
22
lib/tasks/deployment/20190425102459_migrate_virus_scans.rake
Normal file
|
@ -0,0 +1,22 @@
|
|||
namespace :after_party do
|
||||
desc 'Deployment task: migrate_virus_scans'
|
||||
task migrate_virus_scans: :environment do
|
||||
puts "Running deploy task 'migrate_virus_scans'"
|
||||
|
||||
virus_scans = VirusScan.all
|
||||
progress = ProgressReport.new(virus_scans.count)
|
||||
virus_scans.find_each do |virus_scan|
|
||||
blob = ActiveStorage::Blob.find_by(key: virus_scan.blob_key)
|
||||
if blob
|
||||
metadata = { virus_scan_result: virus_scan.status, scanned_at: virus_scan.scanned_at }
|
||||
blob.update_column(:metadata, blob.metadata.merge(metadata))
|
||||
end
|
||||
progress.inc
|
||||
end
|
||||
progress.finish
|
||||
|
||||
# Update task as completed. If you remove the line below, the task will
|
||||
# run with every deploy (or every time you call after_party:run).
|
||||
AfterParty::TaskRecord.create version: '20190425102459'
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue