diff options
Diffstat (limited to 'db/post_migrate/20200723132258_schedule_copy_of_mr_target_project_id_to_mr_metrics.rb')
-rw-r--r-- | db/post_migrate/20200723132258_schedule_copy_of_mr_target_project_id_to_mr_metrics.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/db/post_migrate/20200723132258_schedule_copy_of_mr_target_project_id_to_mr_metrics.rb b/db/post_migrate/20200723132258_schedule_copy_of_mr_target_project_id_to_mr_metrics.rb new file mode 100644 index 00000000000..bca703121bc --- /dev/null +++ b/db/post_migrate/20200723132258_schedule_copy_of_mr_target_project_id_to_mr_metrics.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +class ScheduleCopyOfMrTargetProjectIdToMrMetrics < ActiveRecord::Migration[6.0] + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + INTERVAL = 2.minutes.to_i + BATCH_SIZE = 5_000 + MIGRATION = 'CopyMergeRequestTargetProjectToMergeRequestMetrics' + + disable_ddl_transaction! + + class MergeRequest < ActiveRecord::Base + include EachBatch + + self.table_name = 'merge_requests' + end + + def up + MergeRequest.reset_column_information + + queue_background_migration_jobs_by_range_at_intervals( + MergeRequest, + MIGRATION, + INTERVAL, + batch_size: BATCH_SIZE + ) + end + + def down + # noop + end +end |