Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb')
-rw-r--r--db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb37
1 files changed, 0 insertions, 37 deletions
diff --git a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
deleted file mode 100644
index 51441a36e4b..00000000000
--- a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migration[4.2]
- DOWNTIME = false
- BATCH_SIZE = 10_000
- MIGRATION = 'PopulateMergeRequestMetricsWithEventsData'
-
- disable_ddl_transaction!
-
- class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
-
- include ::EachBatch
- end
-
- def up
- say 'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs'
- # It will update around 4_000_000 records in batches of 10_000 merge
- # requests (running between 10 minutes) and should take around 66 hours to complete.
- # Apparently, production PostgreSQL is able to vacuum 10k-20k dead_tuples by
- # minute, and at maximum, each of these jobs should UPDATE 20k records.
- #
- # More information about the updates in `PopulateMergeRequestMetricsWithEventsData` class.
- #
- MergeRequest.all.each_batch(of: BATCH_SIZE) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
-
- BackgroundMigrationWorker.perform_in(index * 10.minutes, MIGRATION, range)
- end
- end
-
- def down
- execute "update merge_request_metrics set latest_closed_at = null"
- execute "update merge_request_metrics set latest_closed_by_id = null"
- execute "update merge_request_metrics set merged_by_id = null"
- end
-end