diff options
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20201231133921_schedule_set_default_iteration_cadences.rb | 30 |
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 |