Skip to content

Allow customising of queries used for `update_column_in_batches`

yorickpeterse-staging requested to merge update-column-in-batches-where into master

What does this MR do?

This MR makes two changes to add_column_with_default and update_column_in_batches:

  1. add_column_with_default no longer wraps the entire set of updates in a single transaction, preventing any locks from sticking around for the duration of the entire transaction
  2. update_column_in_batches now takes a block which can be used to customise the queries. This uses Arel as messing with raw SQL strings is a total pain

Are there points in the code the reviewer needs to double check?

No.

Why was this MR needed?

In !4381 (merged) there's a need for updating existing rows/columns in a table in batches using a custom WHERE condition. Without the changes in this MR this would not be possible.

What are the relevant issue numbers?

None.

Does this MR meet the acceptance criteria?

Merge request reports