summaryrefslogtreecommitdiff
path: root/app/workers
diff options
context:
space:
mode:
authorGabriel Mazetto <gabriel@gitlab.com>2018-06-07 15:40:44 +0000
committerNick Thomas <nick@gitlab.com>2018-06-07 15:40:44 +0000
commit36c337647591d964b7ef1e1fc61fc64a930fb6f4 (patch)
treedd00844e2b78592b453d04443367eb9879f18c42 /app/workers
parent1b06b8342cc75d948c40c9b74e4c4884a488484e (diff)
downloadgitlab-ce-36c337647591d964b7ef1e1fc61fc64a930fb6f4.tar.gz
Resolve "Hashed Storage: Make possible to migrate single project"
Diffstat (limited to 'app/workers')
-rw-r--r--app/workers/storage_migrator_worker.rb25
1 files changed, 2 insertions, 23 deletions
diff --git a/app/workers/storage_migrator_worker.rb b/app/workers/storage_migrator_worker.rb
index f92421a667d..0aff0c4c7c6 100644
--- a/app/workers/storage_migrator_worker.rb
+++ b/app/workers/storage_migrator_worker.rb
@@ -1,29 +1,8 @@
class StorageMigratorWorker
include ApplicationWorker
- BATCH_SIZE = 100
-
def perform(start, finish)
- projects = build_relation(start, finish)
-
- projects.with_route.find_each(batch_size: BATCH_SIZE) do |project|
- Rails.logger.info "Starting storage migration of #{project.full_path} (ID=#{project.id})..."
-
- begin
- project.migrate_to_hashed_storage!
- rescue => err
- Rails.logger.error("#{err.message} migrating storage of #{project.full_path} (ID=#{project.id}), trace - #{err.backtrace}")
- end
- end
- end
-
- def build_relation(start, finish)
- relation = Project
- table = Project.arel_table
-
- relation = relation.where(table[:id].gteq(start)) if start
- relation = relation.where(table[:id].lteq(finish)) if finish
-
- relation
+ migrator = Gitlab::HashedStorage::Migrator.new
+ migrator.bulk_migrate(start, finish)
end
end