diff options
Diffstat (limited to 'lib/tasks/gitlab/background_migrations.rake')
-rw-r--r-- | lib/tasks/gitlab/background_migrations.rake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/background_migrations.rake b/lib/tasks/gitlab/background_migrations.rake index c978a2807ca..c7f3d003f9f 100644 --- a/lib/tasks/gitlab/background_migrations.rake +++ b/lib/tasks/gitlab/background_migrations.rake @@ -2,6 +2,7 @@ namespace :gitlab do namespace :background_migrations do + desc 'Synchronously finish executing a batched background migration' task :finalize, [:job_class_name, :table_name, :column_name, :job_arguments] => :environment do |_, args| [:job_class_name, :table_name, :column_name, :job_arguments].each do |argument| unless args[argument] @@ -19,5 +20,23 @@ namespace :gitlab do puts "Done.".color(:green) end + + desc 'Display the status of batched background migrations' + task status: :environment do + statuses = Gitlab::Database::BackgroundMigration::BatchedMigration.statuses + max_status_length = statuses.keys.map(&:length).max + format_string = "%-#{max_status_length}s | %s\n" + + Gitlab::Database::BackgroundMigration::BatchedMigration.find_each(batch_size: 100) do |migration| + identification_fields = [ + migration.job_class_name, + migration.table_name, + migration.column_name, + migration.job_arguments.to_json + ].join(',') + + printf(format_string, migration.status, identification_fields) + end + end end end |