summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20180228121020_update_checksum_for_ci_job_artifacts.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/db/post_migrate/20180228121020_update_checksum_for_ci_job_artifacts.rb b/db/post_migrate/20180228121020_update_checksum_for_ci_job_artifacts.rb
new file mode 100644
index 00000000000..bf69c647b4d
--- /dev/null
+++ b/db/post_migrate/20180228121020_update_checksum_for_ci_job_artifacts.rb
@@ -0,0 +1,25 @@
+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