Skip to content

New Migration/UpdateColumnInBatches cop

What does this MR do?

This adds a cop to ensure that any migration that uses update_column_in_batches has a spec file.

Example of offense:

db/migrate/20160615191922_set_missing_stage_on_ci_builds.rb:5:5: C: Migration/UpdateColumnInBatchesSpec: Migration running update_column_in_batches must have a spec file at spec/migrations/20160615191922_set_missing_stage_on_ci_builds_spec.rb.
    update_column_in_batches(:ci_builds, :stage, :test) do |table, query|
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

I've expanded RuboCop::MigrationHelpers#in_migration? to detect migrations in db/post_migrate as well.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #32677 (closed)

Edited by Rémy Coutable

Merge request reports