2017-12-05 11:02:07 +00:00
|
|
|
class ScheduleBuildStageMigration < ActiveRecord::Migration
|
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
MIGRATION = 'MigrateBuildStage'.freeze
|
2018-02-16 11:28:34 +00:00
|
|
|
BATCH_SIZE = 500
|
2018-02-13 15:18:09 +00:00
|
|
|
|
|
|
|
disable_ddl_transaction!
|
2017-12-05 11:02:07 +00:00
|
|
|
|
|
|
|
class Build < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
self.table_name = 'ci_builds'
|
|
|
|
end
|
|
|
|
|
2018-02-13 15:18:09 +00:00
|
|
|
def up
|
|
|
|
disable_statement_timeout
|
|
|
|
|
2018-02-16 11:28:34 +00:00
|
|
|
Build.where('stage_id IS NULL').tap do |relation|
|
|
|
|
queue_background_migration_jobs_by_range_at_intervals(relation,
|
|
|
|
MIGRATION,
|
|
|
|
5.minutes,
|
|
|
|
batch_size: BATCH_SIZE)
|
2017-12-05 11:02:07 +00:00
|
|
|
end
|
|
|
|
end
|
2018-02-13 15:18:09 +00:00
|
|
|
|
|
|
|
def down
|
|
|
|
# noop
|
|
|
|
end
|
2017-12-05 11:02:07 +00:00
|
|
|
end
|