diff options
Diffstat (limited to 'db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb')
-rw-r--r-- | db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb deleted file mode 100644 index 39666a0cd2a..00000000000 --- a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb +++ /dev/null @@ -1,44 +0,0 @@ -class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Migration[4.2] - include Gitlab::Database::MigrationHelpers - - DOWNTIME = false - BATCH_SIZE = 5_000 - MIGRATION = 'PopulateMergeRequestMetricsWithEventsData' - DELAY_INTERVAL = 10.minutes - - disable_ddl_transaction! - - class MergeRequest < ActiveRecord::Base - self.table_name = 'merge_requests' - - include ::EachBatch - end - - def up - # Perform any ongoing background migration that might still be running. This - # avoids scheduling way too many of the same jobs on self-hosted instances - # if they're updating GitLab across multiple versions. The "Take one" - # migration was executed on 10.4 on - # SchedulePopulateMergeRequestMetricsWithEventsData. - Gitlab::BackgroundMigration.steal(MIGRATION) - - metrics_not_exists_clause = <<~SQL - NOT EXISTS (SELECT 1 FROM merge_request_metrics - WHERE merge_request_metrics.merge_request_id = merge_requests.id) - SQL - - relation = MergeRequest.where(metrics_not_exists_clause) - - # We currently have ~400_000 MR records without metrics on GitLab.com. - # This means it'll schedule ~80 jobs (5000 MRs each) with a 10 minutes gap, - # so this should take ~14 hours for all background migrations to complete. - # - queue_background_migration_jobs_by_range_at_intervals(relation, - MIGRATION, - DELAY_INTERVAL, - batch_size: BATCH_SIZE) - end - - def down - end -end |