summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/uploads/migrate.rake
blob: 80290f95e8e38d2cf5cbb47831f5010e1563e9b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

namespace :gitlab do
  namespace :uploads do
    namespace :migrate do
      desc "GitLab | Uploads | Migrate all uploaded files to object storage"
      task all: :environment do
        Gitlab::Uploads::MigrationHelper.categories.each do |args|
          Rake::Task["gitlab:uploads:migrate"].invoke(*args)
          Rake::Task["gitlab:uploads:migrate"].reenable
        end
      end
    end

    # The following is the actual rake task that migrates uploads of specified
    # category to object storage
    desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage'
    task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |_t, args|
      Gitlab::Uploads::MigrationHelper.new(args, Logger.new($stdout)).migrate_to_remote_storage
    end

    namespace :migrate_to_local do
      desc "GitLab | Uploads | Migrate all uploaded files to local storage"
      task all: :environment do
        Gitlab::Uploads::MigrationHelper.categories.each do |args|
          Rake::Task["gitlab:uploads:migrate_to_local"].invoke(*args)
          Rake::Task["gitlab:uploads:migrate_to_local"].reenable
        end
      end
    end

    desc 'GitLab | Uploads | Migrate the uploaded files of specified type to local storage'
    task :migrate_to_local, [:uploader_class, :model_class, :mounted_as] => :environment do |_t, args|
      Gitlab::Uploads::MigrationHelper.new(args, Logger.new($stdout)).migrate_to_local_storage
    end
  end
end