Remove rake task to migrate all legacy attachments

parent 37a4c547
...@@ -7,9 +7,9 @@ class MigrateLegacyAttachments < ActiveRecord::Migration[6.0] ...@@ -7,9 +7,9 @@ class MigrateLegacyAttachments < ActiveRecord::Migration[6.0]
DOWNTIME = false DOWNTIME = false
MIGRATION = 'LegacyUploadsMigrator'.freeze MIGRATION = 'LegacyUploadsMigrator'
BATCH_SIZE = 5000 BATCH_SIZE = 5000
DELAY_INTERVAL = 5.minutes.to_i INTERVAL = 5.minutes.to_i
class Upload < ActiveRecord::Base class Upload < ActiveRecord::Base
self.table_name = 'uploads' self.table_name = 'uploads'
...@@ -18,12 +18,10 @@ class MigrateLegacyAttachments < ActiveRecord::Migration[6.0] ...@@ -18,12 +18,10 @@ class MigrateLegacyAttachments < ActiveRecord::Migration[6.0]
end end
def up def up
Upload.where(uploader: 'AttachmentUploader', model_type: 'Note').each_batch(of: BATCH_SIZE) do |relation, index| queue_background_migration_jobs_by_range_at_intervals(Upload.where(uploader: 'AttachmentUploader', model_type: 'Note'),
start_id, end_id = relation.pluck('MIN(id), MAX(id)').first MIGRATION,
delay = index * delay_interval INTERVAL,
batch_size: BATCH_SIZE)
BackgroundMigrationWorker.perform_in(delay, migration, [start_id, end_id])
end
end end
def down def down
......
...@@ -111,24 +111,6 @@ sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, MergeReque ...@@ -111,24 +111,6 @@ sudo -u git -H bundle exec rake "gitlab:uploads:migrate[FileUploader, MergeReque
sudo -u git -H bundle exec rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action]" sudo -u git -H bundle exec rake "gitlab:uploads:migrate[DesignManagement::DesignV432x230Uploader, DesignManagement::Action]"
``` ```
## Migrate legacy uploads out of deprecated paths
> Introduced in GitLab 12.3.
To migrate all uploads created by legacy uploaders, run:
**Omnibus Installation**
```shell
gitlab-rake gitlab:uploads:legacy:migrate
```
**Source Installation**
```shell
bundle exec rake gitlab:uploads:legacy:migrate
```
## Migrate from object storage to local storage ## Migrate from object storage to local storage
If you need to disable Object Storage for any reason, first you need to migrate If you need to disable Object Storage for any reason, first you need to migrate
......
# frozen_string_literal: true
namespace :gitlab do
namespace :uploads do
namespace :legacy do
desc "GitLab | Uploads | Migrate all legacy attachments"
task migrate: :environment do
class Upload < ApplicationRecord
self.table_name = 'uploads'
include ::EachBatch
end
migration = 'LegacyUploadsMigrator'
batch_size = 5000
delay_interval = 5.minutes.to_i
Upload.where(uploader: 'AttachmentUploader', model_type: 'Note').each_batch(of: batch_size) do |relation, index|
start_id, end_id = relation.pluck('MIN(id), MAX(id)').first
delay = index * delay_interval
BackgroundMigrationWorker.perform_in(delay, migration, [start_id, end_id])
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment