gitlab-org--gitlab-foss/db/migrate/20180420010616_cleanup_buil...

29 lines
608 B
Ruby
Raw Normal View History

class CleanupBuildStageMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_builds'
self.inheritance_column = :_type_disabled
end
def up
Gitlab::BackgroundMigration.steal('MigrateBuildStage')
Build.where('stage_id IS NULL').each_batch(of: 50) do |batch|
range = batch.pluck('MIN(id)', 'MAX(id)').first
Gitlab::BackgroundMigration::MigrateBuildStage.new.perform(*range)
end
end
def down
# noop
end
end