summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorFelipe Artur <felipefac@gmail.com>2019-02-19 11:33:30 -0300
committerFelipe Artur <felipefac@gmail.com>2019-02-19 11:33:30 -0300
commit52155d8cf8374e9184c2ae834cab761b7520db93 (patch)
tree2c5251cd425045ff915a250b6cf12a0208811c9b /db
parentcc7a44c8e130a8f3f753ba0ed32e45b0a6b0e6f7 (diff)
downloadgitlab-ce-52155d8cf8374e9184c2ae834cab761b7520db93.tar.gz
Add more specs and code improvements
Diffstat (limited to 'db')
-rw-r--r--db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb31
1 files changed, 20 insertions, 11 deletions
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