summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-11-05 21:26:40 +0100
committerToon Claes <toon@gitlab.com>2018-11-07 11:29:31 +0100
commit16116bb148a7582ad39e026459b9fb7572b8936f (patch)
tree23973515ec833d4cf0525885fb570a3d91a1b7d2 /db
parent149b63272202d78566af59db192c668a8803c910 (diff)
downloadgitlab-ce-16116bb148a7582ad39e026459b9fb7572b8936f.tar.gz
Add migration to steal FillStoreUpload
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20181105201455_steal_fill_store_upload.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/db/post_migrate/20181105201455_steal_fill_store_upload.rb b/db/post_migrate/20181105201455_steal_fill_store_upload.rb
new file mode 100644
index 00000000000..982001fedbe
--- /dev/null
+++ b/db/post_migrate/20181105201455_steal_fill_store_upload.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class StealFillStoreUpload < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 10_000
+
+ disable_ddl_transaction!
+
+ class Upload < ActiveRecord::Base
+ include EachBatch
+
+ self.table_name = 'uploads'
+ self.inheritance_column = :_type_disabled # Disable STI
+ end
+
+ def up
+ Gitlab::BackgroundMigration.steal('FillStoreUpload')
+
+ Upload.where(store: nil).each_batch(of: BATCH_SIZE) do |batch|
+ range = batch.pluck('MIN(id)', 'MAX(id)').first
+
+ Gitlab::BackgroundMigration::FillStoreUpload.new.perform(*range)
+ end
+ end
+
+ def down
+ # noop
+ end
+end