Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/database/migrations/batched_background_migration_helpers.rb')
-rw-r--r--lib/gitlab/database/migrations/batched_background_migration_helpers.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/gitlab/database/migrations/batched_background_migration_helpers.rb b/lib/gitlab/database/migrations/batched_background_migration_helpers.rb
index 0261ade0fe7..7113c3686f1 100644
--- a/lib/gitlab/database/migrations/batched_background_migration_helpers.rb
+++ b/lib/gitlab/database/migrations/batched_background_migration_helpers.rb
@@ -122,6 +122,22 @@ module Gitlab
migration.save!
migration
end
+
+ def finalize_batched_background_migration(job_class_name:, table_name:, column_name:, job_arguments:)
+ database_name = Gitlab::Database.db_config_name(connection)
+
+ unless ActiveRecord::Base.configurations.primary?(database_name)
+ raise 'The `#finalize_background_migration` is currently not supported when running in decomposed database, ' \
+ 'and this database is not `main:`. For more information visit: ' \
+ 'https://docs.gitlab.com/ee/development/database/migrations_for_multiple_databases.html'
+ end
+
+ migration = Gitlab::Database::BackgroundMigration::BatchedMigration.find_for_configuration(job_class_name, table_name, column_name, job_arguments)
+
+ raise 'Could not find batched background migration' if migration.nil?
+
+ Gitlab::Database::BackgroundMigration::BatchedMigrationRunner.finalize(job_class_name, table_name, column_name, job_arguments, connection: connection)
+ end
end
end
end