Class: Gitlab::BackgroundMigration::LegacyUploadsMigrator

Inherits:
Object
  • Object
show all
Includes:
Database::MigrationHelpers
Defined in:
lib/gitlab/background_migration/legacy_uploads_migrator.rb

Overview

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.

Constant Summary

Constants included from Database::MigrationHelpers

Database::MigrationHelpers::DEFAULT_TIMESTAMP_COLUMNS, Database::MigrationHelpers::MAX_IDENTIFIER_NAME_LENGTH, Database::MigrationHelpers::PERMITTED_TIMESTAMP_COLUMNS

Constants included from Database::Migrations::BackgroundMigrationHelpers

Database::Migrations::BackgroundMigrationHelpers::BACKGROUND_MIGRATION_BATCH_SIZE, Database::Migrations::BackgroundMigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE

Instance Method Summary collapse

Methods included from Database::MigrationHelpers

#add_check_constraint, #add_column_with_default, #add_concurrent_foreign_key, #add_concurrent_index, #add_not_null_constraint, #add_text_limit, #add_timestamps_with_timezone, #backfill_iids, #change_column_type_concurrently, #change_column_type_using_background_migration, #check_constraint_exists?, #check_constraint_name, #check_not_null_constraint_exists?, #check_text_limit_exists?, #check_trigger_permissions!, #cleanup_concurrent_column_rename, #cleanup_concurrent_column_type_change, #column_for, #concurrent_foreign_key_name, #copy_foreign_keys, #copy_indexes, #create_extension, #create_or_update_plan_limit, #disable_statement_timeout, #drop_extension, #false_value, #foreign_key_exists?, #foreign_keys_for, #index_exists_by_name?, #indexes_for, #install_rename_triggers, #install_rename_triggers_for_postgresql, #postgres_exists_by_name?, #remove_check_constraint, #remove_concurrent_index, #remove_concurrent_index_by_name, #remove_foreign_key_if_exists, #remove_foreign_key_without_error, #remove_not_null_constraint, #remove_rename_triggers_for_postgresql, #remove_text_limit, #remove_timestamps, #rename_column_concurrently, #rename_column_using_background_migration, #rename_trigger_name, #replace_sql, #sidekiq_queue_length, #sidekiq_queue_migrate, #true_value, #undo_cleanup_concurrent_column_rename, #undo_rename_column_concurrently, #update_column_in_batches, #validate_check_constraint, #validate_foreign_key, #validate_not_null_constraint, #validate_text_limit, #with_lock_retries

Methods included from Database::Migrations::BackgroundMigrationHelpers

#bulk_migrate_async, #bulk_migrate_in, #bulk_queue_background_migration_jobs_by_range, #migrate_async, #migrate_in, #perform_background_migration_inline?, #queue_background_migration_jobs_by_range_at_intervals, #with_migration_context

Instance Method Details

#perform(start_id, end_id) ⇒ Object


16
17
18
19
20
# File 'lib/gitlab/background_migration/legacy_uploads_migrator.rb', line 16

def perform(start_id, end_id)
  Upload.where(id: start_id..end_id, uploader: 'AttachmentUploader', model_type: 'Note').find_each do |upload|
    LegacyUploadMover.new(upload).execute
  end
end