2019-02-14 13:48:20 +00:00
|
|
|
class ScheduleSyncIssuablesStateId < ActiveRecord::Migration[5.0]
|
2019-02-19 14:33:30 +00:00
|
|
|
# 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
|
|
|
|
|
2019-02-14 13:48:20 +00:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
2019-02-19 14:33:30 +00:00
|
|
|
# 2019-02-12 gitlab.com issuable numbers
|
2019-02-14 13:48:20 +00:00
|
|
|
# issues count: 13587305
|
|
|
|
# merge requests count: 18925274
|
2019-02-19 14:33:30 +00:00
|
|
|
#
|
|
|
|
# Using 25000 as batch size should take around 26 hours
|
2019-02-14 13:48:20 +00:00
|
|
|
# to migrate both issues and merge requests
|
|
|
|
BATCH_SIZE = 25000
|
|
|
|
DELAY_INTERVAL = 5.minutes.to_i
|
2019-02-19 14:33:30 +00:00
|
|
|
ISSUES_MIGRATION = 'SyncIssuesStateId'.freeze
|
|
|
|
MERGE_REQUESTS_MIGRATION = 'SyncMergeRequestsStateId'.freeze
|
2019-02-14 13:48:20 +00:00
|
|
|
|
|
|
|
class Issue < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
|
|
|
|
self.table_name = 'issues'
|
|
|
|
end
|
|
|
|
|
|
|
|
class MergeRequest < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
|
|
|
|
self.table_name = 'merge_requests'
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
|
|
|
Sidekiq::Worker.skipping_transaction_check do
|
2019-02-19 14:33:30 +00:00
|
|
|
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
|
|
|
|
)
|
2019-02-14 13:48:20 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# No op
|
|
|
|
end
|
|
|
|
end
|