Use constant to refer to main database name
What does this MR do and why?
Related to #343047 (closed)
Introduce a constant that defines the default tracking database for background migrations and use it throughout, rather than various different hardcoded values of 'main'
or :main
.
This is part of the effort to make background migrations work with multiple databases, and so a transitional change to the end state. Once we have wired up the migration helpers to use the target database of the migration as the tracking database, we can remove the default database altogether and rely solely on the worker definition of their tracking databases.
How to set up and validate locally
The intent of this MR is to keep the current behavior the same, so we can directly exercise the worker to ensure it runs the job:
-
Setup some test migration job class:
module Gitlab module BackgroundMigration class MyTestJob def perform(*args) puts "args: #{args}" end end end end
-
Run the job inline with the existing worker:
BackgroundMigrationWorker.new.perform('MyTestJob', [10, 20])
-
Verify the output looks similar to:
args: [10, 20]
-
Schedule the job to run at a later time:
BackgroundMigrationWorker.perform_in(1.week, 'MyTestJob', [20, 30])
-
Force the job to run now anyhow:
Gitlab::BackgroundMigration.steal('MyTestJob')
-
Verify the output looks similar to:
args: [20, 30]
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.