Resolve "Make `finalize_batched_background_migration` to work properly with many DBs "
Context
When we run db:migrate:[database]
, activerecord points the ActiveRecord::Base.connection
to the database passed in context.
Example:
If we run db:migrate:ci
, activerecord will point ActiveRecord::Base
to the :ci
database.
This breaks the usage of the finalize_batched_background_migration
method for CI.
To fix this, we are using with_restored_connection_stack
that completely rewrites the connection
stack.
Related to #362268 (closed) #358430 (closed)
Edited by Kamil Trzciński