Skip to content

Ensure each BBM has an appropriate data dictionary file

What does this MR do and why?

!110740 (merged) - added support to generate the dictionary file for BBM on using the generator (batched_background_migration).

But there can be cases where BBM related files being manually created, so this MR introduces a new rubocop rule to ensure the presence of the dictionary file.

Note:

The new cop will have a grace period to make sure the build is not failing for BBM (parallel) MRs without valid dictionary file.

Screenshots or screen recordings

Example migration with offense: Screenshot_2023-03-08_at_20.07.24

How to set up and validate locally

  1. Create a test batched_background_migration using bundle exec rails g batched_background_migration my_batched_migration --table_name=users --column_name=id --feature_category=database
  2. The above command should create below files
       create  db/post_migrate/20230308185403_queue_my_batched_migration.rb
       create  spec/migrations/20230308185403_queue_my_batched_migration_spec.rb
       create  lib/gitlab/background_migration/my_batched_migration.rb
       create  spec/lib/gitlab/background_migration/my_batched_migration_spec.rb
       create  db/docs/batched_background_migrations/my_batched_migration.yml
  3. Runnig the cop for migration (bundle exec rubocop db/post_migrate/20230308185403_queue_my_batched_migration.rb --only BackgroundMigration/MissingDictionaryFile --cache false) should not show any offense.
  4. Try removing the dictionary file, in this case rm db/docs/batched_background_migrations/my_batched_migration.yml
  5. Re-running step (3) should display an offense now.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Closes #387584 (closed)

Edited by Prabakaran Murugesan

Merge request reports