提交 99b0542c 编写于 作者: S Shinya Maeda

Add post migration for checksum calculation

上级 22a7f1f9
......@@ -104,3 +104,5 @@
- update_user_activity
- upload_checksum
- 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% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册