2018-11-13 02:27:31 -05:00
|
|
|
class FillFileStore < ActiveRecord::Migration[4.2]
|
2018-04-24 03:43:19 -04:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
disable_ddl_transaction!
|
|
|
|
|
|
|
|
class JobArtifact < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
self.table_name = 'ci_job_artifacts'
|
|
|
|
BATCH_SIZE = 10_000
|
|
|
|
|
2018-04-27 01:46:03 -04:00
|
|
|
def self.params_for_background_migration
|
|
|
|
yield self.where(file_store: nil), 'FillFileStoreJobArtifact', 5.minutes, BATCH_SIZE
|
2018-04-24 03:43:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class LfsObject < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
self.table_name = 'lfs_objects'
|
|
|
|
BATCH_SIZE = 10_000
|
|
|
|
|
2018-04-27 01:46:03 -04:00
|
|
|
def self.params_for_background_migration
|
|
|
|
yield self.where(file_store: nil), 'FillFileStoreLfsObject', 5.minutes, BATCH_SIZE
|
2018-04-24 03:43:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class Upload < ActiveRecord::Base
|
|
|
|
include EachBatch
|
|
|
|
self.table_name = 'uploads'
|
2018-05-18 04:04:05 -04:00
|
|
|
self.inheritance_column = :_type_disabled # Disable STI
|
2018-04-24 03:43:19 -04:00
|
|
|
BATCH_SIZE = 10_000
|
|
|
|
|
2018-04-27 01:46:03 -04:00
|
|
|
def self.params_for_background_migration
|
2018-05-18 04:04:05 -04:00
|
|
|
yield self.where(store: nil), 'FillStoreUpload', 5.minutes, BATCH_SIZE
|
2018-04-24 03:43:19 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def up
|
2018-04-27 01:31:26 -04:00
|
|
|
# NOTE: Schedule background migrations that fill 'NULL' value by '1'(ObjectStorage::Store::LOCAL) on `file_store`, `store` columns
|
2018-07-25 04:59:23 -04:00
|
|
|
#
|
2018-04-27 01:31:26 -04:00
|
|
|
# Here are the target columns
|
|
|
|
# - ci_job_artifacts.file_store
|
|
|
|
# - lfs_objects.file_store
|
|
|
|
# - uploads.store
|
2018-04-24 03:43:19 -04:00
|
|
|
|
2018-04-27 01:46:03 -04:00
|
|
|
FillFileStore::JobArtifact.params_for_background_migration do |relation, class_name, delay_interval, batch_size|
|
|
|
|
queue_background_migration_jobs_by_range_at_intervals(relation,
|
|
|
|
class_name,
|
|
|
|
delay_interval,
|
|
|
|
batch_size: batch_size)
|
|
|
|
end
|
|
|
|
|
|
|
|
FillFileStore::LfsObject.params_for_background_migration do |relation, class_name, delay_interval, batch_size|
|
|
|
|
queue_background_migration_jobs_by_range_at_intervals(relation,
|
|
|
|
class_name,
|
|
|
|
delay_interval,
|
|
|
|
batch_size: batch_size)
|
|
|
|
end
|
|
|
|
|
|
|
|
FillFileStore::Upload.params_for_background_migration do |relation, class_name, delay_interval, batch_size|
|
|
|
|
queue_background_migration_jobs_by_range_at_intervals(relation,
|
|
|
|
class_name,
|
|
|
|
delay_interval,
|
|
|
|
batch_size: batch_size)
|
|
|
|
end
|
2018-04-24 03:43:19 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
# noop
|
|
|
|
end
|
|
|
|
end
|