Commit 99b0542c authored by Shinya Maeda's avatar Shinya Maeda

Add post migration for checksum calculation

parent 22a7f1f9
...@@ -104,3 +104,5 @@ ...@@ -104,3 +104,5 @@
- update_user_activity - update_user_activity
- upload_checksum - upload_checksum
- web_hook - web_hook
- object_storage:update_artifact_checksum_worker
\ No newline at end of file
class UpdateArtifactChecksumWorker
include ApplicationWorker
include ObjectStorageQueue
def perform(job_artifact_id)
Ci::JobArtifact.find_by(id: job_artifact_id).try do |job_artifact|
job_artifact.set_checksum
job_artifact.save!
end
end
end
class UpdateChecksumForCiJobArtifacts < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
BATCH_SIZE = 2500
class JobArtifact < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_job_artifacts'
end
def up
UpdateChecksumForCiJobArtifacts::JobArtifact
.where('checksum IS NULL')
.each_batch(of: BATCH_SIZE) do |relation|
ids = relation.pluck(:id).map { |id| [id] }
UpdateArtifactChecksumWorker.bulk_perform_async(ids)
end
end
def down
# no-op
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment