Avoid name collision between migrations
What does this MR do and why?
Adds a pre-push hook to check name clashing between db migrations and Elasticsearch migrations.
How to set up and validate locally
Method 1
- Pick a migration in
db/migrate, likedb/migrate/20220421114418_make_fingerprint_nullable_for_group_deploy_key.rb - Change the class name to some class that it's already present in
ee/elastic/migrate, likeAddUpvotesMappingsToMergeRequests. - run
./scripts/validate_name_collisions_between_migrations - Should get the following output:
Error: Naming collisions were found between migrations
AddUpvotesMappingsToMergeRequests: /Users/leonardodarosa/gdk/gitlab/db/migrate/20220421114418_make_fingerprint_nullable_for_group_deploy_key.rb, /Users/leonardodarosa/gdk/gitlab/ee/elastic/migrate/20210722112500_add_upvotes_mappings_to_merge_requests.rb
Method 2
- Pick a migration in
db/migrate, likedb/migrate/20220421114418_make_fingerprint_nullable_for_group_deploy_key.rb - Change the class name to some class that it's already present in
ee/elastic/migrate, likeAddUpvotesMappingsToMergeRequests. CommitPush
Lefthook v1.4.7
RUNNING HOOK: pre-commit
...
RUNNING HOOK: pre-push
...
EXECUTE > db-migration-name-collisions
Error: Naming collisions were found between migrations
AddUpvotesMappingsToMergeRequests: /Users/leonardodarosa/gdk/gitlab/db/migrate/20220421114418_make_fingerprint_nullable_for_group_deploy_key.rb, /Users/leonardodarosa/gdk/gitlab/ee/elastic/migrate/20210722112500_add_upvotes_mappings_to_merge_requests.rb
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 #419193 (closed)
Edited by Peter Leitzen