ee79ee9473
Add migration and spec commit 3cc12e1268a6865f524d8fab1804f018312fdf5a Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Jan 8 19:34:31 2019 +0900 Add changelog to this change commit 5006fc96e38db514956a35f53ae8ee536548a2e9 Author: Shinya Maeda <shinya@gitlab.com> Date: Tue Jan 8 19:32:56 2019 +0900 Remove partial index from ci_builds artifact_file ok Update schema commit 3c956bdc02b195bc67d0327bf3748a631ea5466d Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jan 7 21:41:27 2019 +0900 Add frozen_string_literal: true commit 8c827cd616890160e6e8908843403a6f20c03236 Author: Shinya Maeda <shinya@gitlab.com> Date: Mon Jan 7 21:40:06 2019 +0900 Set batch size 100 commit aeee559777d3bdeadfd2b9bb61d460f2dc1fa8a6 Author: Shinya Maeda <shinya@gitlab.com> Date: Fri Jan 4 18:33:05 2019 +0900 Cleanup legacy artifact background migration
34 lines
774 B
Ruby
34 lines
774 B
Ruby
# frozen_string_literal: true
|
|
|
|
class CleanupLegacyArtifactMigration < ActiveRecord::Migration[5.0]
|
|
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
|
|
|
|
scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") }
|
|
end
|
|
|
|
def up
|
|
Gitlab::BackgroundMigration.steal('MigrateLegacyArtifacts')
|
|
|
|
CleanupLegacyArtifactMigration::Build
|
|
.with_legacy_artifacts
|
|
.each_batch(of: 100) do |batch|
|
|
range = batch.pluck('MIN(id)', 'MAX(id)').first
|
|
|
|
Gitlab::BackgroundMigration::MigrateLegacyArtifacts.new.perform(*range)
|
|
end
|
|
end
|
|
|
|
def down
|
|
# no-op
|
|
end
|
|
end
|