Update generic BG migration jobs to use correct context
Some background migrations we use from migration helpers are generic, in that they don't know ahead of time which database they'll talk to. For example, the BackfillPartitionedTable
can be run either the main
or ci
database, depending on the target table, but it doesn't (nor should it) have information to decide which database connection to use.
For these migration jobs, we should have a way to provide the surrounding context from the execution of the job, which is already correctly configured. Through a base class or other means we can expose the current context, which contains the connection to the tracking database, and methods like steal
which already know their target worker.
We can also expand this to include useful helpers, like base models for each database which don't rely on application classes (ApplicationRecord
).