Ensure the presence of required attrs in BBM dict
What does this MR do and why?
We need to make few attrs mandatory to support BBM dependencies framework. Eg: Run a cron to create a new issue after 'finaliz... (#424886 - closed) requires introduced_by_url, finalize_after values to be present.
Highlights:
- Renamed existing BackgroundMigration/MissingDictionaryFile cop to BackgroundMigration/DictionaryFile, to support missing keys offense too.
- Added the grace period to avoid any failures in the default branch pipelines.
- Included
enforcedSince
to not include existing migrations without required keys.- Created #428935 (closed) to handle those.
How to set up and validate locally
-
Enqueue a new batched background migration (my_batched_migration).
bundle exec rails g batched_background_migration my_batched_migration --table_name=projects --column_name=id --feature_category=database
-
With default values in the dictionary (empty introduced_by_url and finalize_after keys), it should throw an offense
bundle exec rubocop --cache false db/post_migrate/20231020150948_queue_my_batched_migration.rb db/post_migrate/20231020150948_queue_my_batched_migration.rb:8:1: C: BackgroundMigration/DictionaryFile: Mandatory key 'finalize_after' is missing from the dictionary. Please add with an appropriate value. class QueueMyBatchedMigration < Gitlab::Database::Migration[2.1] ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
Add a value for finalize_after in
db/docs/batched_background_migrations/my_batched_migration.yml
, should still throw an offense for missingintroduced_by_url
.bundle exec rubocop --cache false db/post_migrate/20231020150948_queue_my_batched_migration.rb Inspecting 1 file C Offenses: db/post_migrate/20231020150948_queue_my_batched_migration.rb:8:1: C: BackgroundMigration/DictionaryFile: Mandatory key 'introduced_by_url' is missing from the dictionary. Please add with an appropriate value. class QueueMyBatchedMigration < Gitlab::Database::Migration[2.1] ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 file inspected, 1 offense detected
-
Add a value for
introduced_by_url
too, now it shouldn't throw any offense.bundle exec rubocop --cache false db/post_migrate/20231020150948_queue_my_batched_migration.rb Inspecting 1 file . 1 file inspected, no offenses detected
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.
Related to #424883 (closed)