Skip to content

Resolve "Scoping support for batching strategies + new DSL for batched background migrations"

What does this MR do and why?

In this MR, we are introducing the following features:

  • Scoping support for batching strategies and jobs.
  • New DSL for Batched Background Migrations
  • Documentation improvement

Using the new DSL, we can define the operation_name, add a scope (this scope will apply to the batching strategy + job by default), and define job_arguments.

Example:

operation_name :update_all
scope -> (relation, job_arguments) { relation.where.not(bar: nil) }
job_arguments :type_x, :type_y

Note:

Since the class method scope is a singleton and the content is a lambda function, we cannot use the job_arguments defined at the top of the class.

Example:

scope -> (relation, job_arguments) { relation.where.not(bar: job_arguments.first) }
job_arguments :type_x, :type_y

I will add as a follow-up a new MR to add more examples to the documentation.

POC link: !90846 (closed)

Screenshots or screen recordings

These are strongly recommended to assist reviewers and reduce the time to merge your change.

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.

Related to #357900 (closed)

Edited by Diogo Frazão

Merge request reports