From 52155d8cf8374e9184c2ae834cab761b7520db93 Mon Sep 17 00:00:00 2001 From: Felipe Artur Date: Tue, 19 Feb 2019 11:33:30 -0300 Subject: Add more specs and code improvements --- ...90214112022_schedule_sync_issuables_state_id.rb | 31 ++++++++++++++-------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'db/post_migrate') diff --git a/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb b/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb index d9b77d2f02c..898bad043ac 100644 --- a/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb +++ b/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb @@ -1,22 +1,22 @@ -# frozen_string_literal: true - -# See http://doc.gitlab.com/ce/development/migration_style_guide.html -# for more information on how to write migrations for GitLab. - class ScheduleSyncIssuablesStateId < ActiveRecord::Migration[5.0] + # This migration schedules the sync of state_id for issues and merge requests + # which are converting the state column from string to integer. + # For more information check: https://gitlab.com/gitlab-org/gitlab-ce/issues/51789 + include Gitlab::Database::MigrationHelpers DOWNTIME = false - # 2019-02-12 Gitlab.com issuable numbers + # 2019-02-12 gitlab.com issuable numbers # issues count: 13587305 # merge requests count: 18925274 - # Using this 25000 as batch size should take around 26 hours + # + # Using 25000 as batch size should take around 26 hours # to migrate both issues and merge requests BATCH_SIZE = 25000 DELAY_INTERVAL = 5.minutes.to_i - ISSUE_MIGRATION = 'SyncIssuesStateId'.freeze - MERGE_REQUEST_MIGRATION = 'SyncMergeRequestsStateId'.freeze + ISSUES_MIGRATION = 'SyncIssuesStateId'.freeze + MERGE_REQUESTS_MIGRATION = 'SyncMergeRequestsStateId'.freeze class Issue < ActiveRecord::Base include EachBatch @@ -32,8 +32,17 @@ class ScheduleSyncIssuablesStateId < ActiveRecord::Migration[5.0] def up Sidekiq::Worker.skipping_transaction_check do - queue_background_migration_jobs_by_range_at_intervals(Issue.where(state_id: nil), ISSUE_MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) - queue_background_migration_jobs_by_range_at_intervals(MergeRequest.where(state_id: nil), MERGE_REQUEST_MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) + queue_background_migration_jobs_by_range_at_intervals(Issue.where(state_id: nil), + ISSUES_MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE + ) + + queue_background_migration_jobs_by_range_at_intervals(MergeRequest.where(state_id: nil), + MERGE_REQUESTS_MIGRATION, + DELAY_INTERVAL, + batch_size: BATCH_SIZE + ) end end -- cgit v1.2.1