Improve background migration helpers
What does this MR do and why?
Update helpers to process background migrations with different gitlab_schema
when it is compatible with the connection.
This will resolve issues with migrations not being found when table's gitlab_schema
change while migration is in progress.
References
Please include cross links to any resources that are relevant to this MR. This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
- Create migration with
restrict_gitlab_migration gitlab_schema: :gitlab_main
to enqueue background migration. - Create another migration with
restrict_gitlab_migration gitlab_schema: :gitlab_main_cell
to finalize it. - Run
DBLAB_ENVIRONMENT=true be rails db:migrate
- On master this will fail with
StandardError: An error has occurred, all later migrations canceled: called ensure_batched_background_migration_is_finished with non-existent migration name
- On this branch it will succeed and the migration will be finalized.
- On master this will fail with
Related to #503461
Edited by Krasimir Angelov