diff options
| author | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-28 16:40:42 +0000 |
|---|---|---|
| committer | Kamil Trzciński <ayufan@ayufan.eu> | 2018-05-28 16:40:42 +0000 |
| commit | 8adf5395bd4a6b81ddc96935bbbf441cca1b4259 (patch) | |
| tree | 7d72892bcc4faecbb780d4287aa504d60943c67d /db | |
| parent | 98b1d76c462788f1afa65721d9ada75d3d98be02 (diff) | |
| parent | fb77cd72821db2ffb8e3c89fa4bb2b0e95de6658 (diff) | |
| download | gitlab-ce-8adf5395bd4a6b81ddc96935bbbf441cca1b4259.tar.gz | |
Merge branch 'add-background-migration-to-fill-file-store' into 'master'
Add background migration to fill file stores from `NULL` to `1`
Closes #45337 and #45476
See merge request gitlab-org/gitlab-ce!18557
Diffstat (limited to 'db')
| -rw-r--r-- | db/post_migrate/20180424151928_fill_file_store.rb | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/db/post_migrate/20180424151928_fill_file_store.rb b/db/post_migrate/20180424151928_fill_file_store.rb new file mode 100644 index 00000000000..b41feb233be --- /dev/null +++ b/db/post_migrate/20180424151928_fill_file_store.rb @@ -0,0 +1,72 @@ +class FillFileStore < ActiveRecord::Migration + 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 + + def self.params_for_background_migration + yield self.where(file_store: nil), 'FillFileStoreJobArtifact', 5.minutes, BATCH_SIZE + end + end + + class LfsObject < ActiveRecord::Base + include EachBatch + self.table_name = 'lfs_objects' + BATCH_SIZE = 10_000 + + def self.params_for_background_migration + yield self.where(file_store: nil), 'FillFileStoreLfsObject', 5.minutes, BATCH_SIZE + end + end + + class Upload < ActiveRecord::Base + include EachBatch + self.table_name = 'uploads' + self.inheritance_column = :_type_disabled # Disable STI + BATCH_SIZE = 10_000 + + def self.params_for_background_migration + yield self.where(store: nil), 'FillStoreUpload', 5.minutes, BATCH_SIZE + end + end + + def up + # NOTE: Schedule background migrations that fill 'NULL' value by '1'(ObjectStorage::Store::LOCAL) on `file_store`, `store` columns + # + # Here are the target columns + # - ci_job_artifacts.file_store + # - lfs_objects.file_store + # - uploads.store + + 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 + end + + def down + # noop + end +end |
