summaryrefslogtreecommitdiff
path: root/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2019-04-01 17:36:11 +0300
committerIgor Drozdov <idrozdov@gitlab.com>2019-04-01 17:36:11 +0300
commit04bb35a4b562fd57b14c55645bb1848a50cdef56 (patch)
tree1bd1ac2af6a5c088ac2529cdbccceeca402d3ebe /db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb
parentade207e575ab846f6d354aaccc1382a6e512dd0d (diff)
parentb8118a65d595040bfce2d83d5e38dd63ebfedb58 (diff)
downloadgitlab-ce-04bb35a4b562fd57b14c55645bb1848a50cdef56.tar.gz
Merge branch 'master' into id-split-self-approval-restrictionsid-split-self-approval-restrictions
Diffstat (limited to 'db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb')
-rw-r--r--db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb b/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb
new file mode 100644
index 00000000000..1ecb38e1a86
--- /dev/null
+++ b/db/post_migrate/20190322132835_schedule_populate_merge_request_assignees_table.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class SchedulePopulateMergeRequestAssigneesTable < ActiveRecord::Migration[5.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 10_000
+ MIGRATION = 'PopulateMergeRequestAssigneesTable'
+ DELAY_INTERVAL = 8.minutes.to_i
+
+ disable_ddl_transaction!
+
+ def up
+ say 'Scheduling `PopulateMergeRequestAssigneesTable` jobs'
+ # We currently have ~4_500_000 merge request records on GitLab.com.
+ # This means it'll schedule ~450 jobs (10k MRs each) with a 8 minutes gap,
+ # so this should take ~60 hours for all background migrations to complete.
+ queue_background_migration_jobs_by_range_at_intervals(MergeRequest, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
+ end
+end