debian-mirror-gitlab/lib/gitlab/background_migration/legacy_uploads_migrator.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
890 B
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
module Gitlab
module BackgroundMigration
# This migration takes all legacy uploads (that were uploaded using AttachmentUploader)
# and migrate them to the new (FileUploader) location (=under projects).
#
# We have dependencies (uploaders) in this migration because extracting code would add a lot of complexity
# and possible errors could appear as the logic in the uploaders is not trivial.
#
# This migration will be removed in 13.0 in order to get rid of a migration that depends on
# the application code.
class LegacyUploadsMigrator
include Database::MigrationHelpers
def perform(start_id, end_id)
2019-12-26 22:10:19 +05:30
Upload.where(id: start_id..end_id, uploader: 'AttachmentUploader', model_type: 'Note').find_each do |upload|
2019-10-12 21:52:04 +05:30
LegacyUploadMover.new(upload).execute
end
end
end
end
end