summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-17 15:09:21 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-17 15:09:21 +0000
commitc982bb363b3a0390a274197f410a1609a4667760 (patch)
tree8be9521106e8e9af432d179f03c5b3af11a0e207 /db/post_migrate
parent75a4eaade04ee758bb3b253f27bf1c20c67991f0 (diff)
downloadgitlab-ce-c982bb363b3a0390a274197f410a1609a4667760.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20201231133921_schedule_set_default_iteration_cadences.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/db/post_migrate/20201231133921_schedule_set_default_iteration_cadences.rb b/db/post_migrate/20201231133921_schedule_set_default_iteration_cadences.rb
new file mode 100644
index 00000000000..2de47915a2f
--- /dev/null
+++ b/db/post_migrate/20201231133921_schedule_set_default_iteration_cadences.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+class ScheduleSetDefaultIterationCadences < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ BATCH_SIZE = 1_000
+ DELAY_INTERVAL = 2.minutes.to_i
+ MIGRATION_CLASS = 'SetDefaultIterationCadences'
+
+ class Iteration < ActiveRecord::Base # rubocop:disable Style/Documentation
+ include EachBatch
+
+ self.table_name = 'sprints'
+ end
+
+ disable_ddl_transaction!
+
+ def up
+ Iteration.select(:group_id).distinct.each_batch(of: BATCH_SIZE, column: :group_id) do |batch, index|
+ group_ids = batch.pluck(:group_id)
+
+ migrate_in(index * DELAY_INTERVAL, MIGRATION_CLASS, group_ids)
+ end
+ end
+
+ def down
+ # Not needed
+ end
+end