Implement DSL to define job arguments for batched migrations
What does this MR do and why?
Introduce new job_arguments
helper so that batched migration jobs can define the job arguments needed.
BatchedMigrationWrapper
will no longer pass job arguments to #perform
. This MR adds a spec to verify no subclasses of BatchedMigrationJob
override #perform
to accepts arguments.
Also update the only two existing migrations that expect arguments passed to #perform
to use the new DSL.
Extracted from !92563 (closed) and !93322 (closed).
Related to #357900 (closed).
Example
Batched migration scheduled with
queue_batched_background_migration(
'CopyColumnUsingBackgroundMigrationJob',
TABLE_NAME,
'name', 'name_convert_to_text',
job_interval: DELAY_INTERVAL
)
must use the helper to define the job arguments, for example
class CopyColumnUsingBackgroundMigrationJob < BatchedMigrationJob
job_arguments :copy_from, :copy_to
def perform
assignment_clauses = build_assignment_clauses(copy_from, copy_to)
each_sub_batch(operation_name: :update_all) do |relation|
relation.update_all(assignment_clauses)
end
end
# ...
end
In this example copy_from
will return name
, and copy_to
will return name_convert_to_text
.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
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.
Related to #357900 (closed)