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:
How to set up and validate locally
- 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
- 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
- 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. - Try removing the dictionary file, in this case
rm db/docs/batched_background_migrations/my_batched_migration.yml
- 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.
-
I have evaluated the MR acceptance checklist for this MR.
Closes #387584 (closed)
Edited by Prabakaran Murugesan