debian-mirror-gitlab/db/post_migrate/20190214112022_schedule_sync_issuables_state_id.rb

59 lines
1.4 KiB
Ruby
Raw Normal View History

2021-03-11 19:13:27 +05:30
# frozen_string_literal: true
2019-07-07 11:18:12 +05:30
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.
2019-12-04 20:38:33 +05:30
# For more information check: https://gitlab.com/gitlab-org/gitlab-foss/issues/51789
2019-07-07 11:18:12 +05:30
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
# 2019-02-12 gitlab.com issuable numbers
# issues count: 13587305
# merge requests count: 18925274
#
# Using 5000 as batch size and 115 seconds interval will give:
# 2718 jobs for issues - taking ~86 hours
# 3786 jobs for merge requests - taking ~120 hours
#
BATCH_SIZE = 5000
DELAY_INTERVAL = 120.seconds.to_i
2021-04-29 21:17:54 +05:30
ISSUES_MIGRATION = 'SyncIssuesStateId'
MERGE_REQUESTS_MIGRATION = 'SyncMergeRequestsStateId'
2019-07-07 11:18:12 +05:30
disable_ddl_transaction!
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
queue_background_migration_jobs_by_range_at_intervals(
Issue.all,
ISSUES_MIGRATION,
DELAY_INTERVAL,
batch_size: BATCH_SIZE
)
queue_background_migration_jobs_by_range_at_intervals(
MergeRequest.all,
MERGE_REQUESTS_MIGRATION,
DELAY_INTERVAL,
batch_size: BATCH_SIZE
)
end
def down
# No op
end
end