Skip to content

Flag usages of `finalize_background_migration` method

What does this MR do and why?

Flags the usage of finalize_background_migration method.

As finalize_background_migration is part of Background Migrations (that is now deprecated), we should point the usage of the correct method ensure_batched_background_migration_is_finished.

How to set up and validate locally

  1. Call finalize_background_migration from any migration in db/post_migration:

I'm using db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb

...
  def up
    finalize_background_migration('MyClass')
  end
...
  1. Inspect the db folder:
❯ bundle exec rubocop ./db

Offenses:

db/post_migrate/20230623073906_prepare_async_index_for_ci_pipelines_bigint_id.rb:9:5: C: Migration/AvoidFinalizeBackgroundMigration: Prefer ensure_batched_background_migration_is_finished over finalize_background_migration in Batched Background Migrations. See https://docs.gitlab.com/ee/development/database/batched_background_migrations.html
    finalize_background_migration('MyClass')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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 #393455 (closed)

Edited by Leonardo da Rosa

Merge request reports

Loading