diff options
| author | Gabriel Mazetto <gabriel@gitlab.com> | 2018-06-07 15:40:44 +0000 |
|---|---|---|
| committer | Nick Thomas <nick@gitlab.com> | 2018-06-07 15:40:44 +0000 |
| commit | 36c337647591d964b7ef1e1fc61fc64a930fb6f4 (patch) | |
| tree | dd00844e2b78592b453d04443367eb9879f18c42 /lib/tasks | |
| parent | 1b06b8342cc75d948c40c9b74e4c4884a488484e (diff) | |
| download | gitlab-ce-36c337647591d964b7ef1e1fc61fc64a930fb6f4.tar.gz | |
Resolve "Hashed Storage: Make possible to migrate single project"
Diffstat (limited to 'lib/tasks')
| -rw-r--r-- | lib/tasks/gitlab/storage.rake | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake index 68d6f9d7cb1..f539b1df955 100644 --- a/lib/tasks/gitlab/storage.rake +++ b/lib/tasks/gitlab/storage.rake @@ -2,9 +2,26 @@ namespace :gitlab do namespace :storage do desc 'GitLab | Storage | Migrate existing projects to Hashed Storage' task migrate_to_hashed: :environment do - legacy_projects_count = Project.with_unmigrated_storage.count + storage_migrator = Gitlab::HashedStorage::Migrator.new helper = Gitlab::HashedStorage::RakeHelper + if helper.range_single_item? + project = Project.with_unmigrated_storage.find_by(id: helper.range_from) + + unless project + puts "There are no projects requiring storage migration with ID=#{helper.range_from}" + + next + end + + puts "Enqueueing storage migration of #{project.full_path} (ID=#{project.id})..." + storage_migrator.migrate(project) + + next + end + + legacy_projects_count = Project.with_unmigrated_storage.count + if legacy_projects_count == 0 puts 'There are no projects requiring storage migration. Nothing to do!' @@ -14,7 +31,7 @@ namespace :gitlab do print "Enqueuing migration of #{legacy_projects_count} projects in batches of #{helper.batch_size}" helper.project_id_batches do |start, finish| - StorageMigratorWorker.perform_async(start, finish) + storage_migrator.bulk_schedule(start, finish) print '.' end |
