Prevent name clash between database and search migrations
While working on !126111 (closed), I've noticed that there is a search migration that has the same name as a database migration. This leads to TypeError (superclass mismatch for class AddInternalToNotes)
- https://gitlab.com/gitlab-org/gitlab/-/jobs/4692103642#L3916.
This can be reproduced locally:
[1] pry(main)> load 'db/migrate/20220907124320_add_internal_to_notes.rb'
=> true
[2] pry(main)> load 'ee/elastic/migrate/20230111142636_add_internal_to_notes.rb'
TypeError: superclass mismatch for class AddInternalToNotes
from ee/elastic/migrate/20230111142636_add_internal_to_notes.rb:3:in `<main>'
same happens in the other direction:
[1] pry(main)> load 'ee/elastic/migrate/20230111142636_add_internal_to_notes.rb'
=> true
[2] pry(main)> load 'db/migrate/20220907124320_add_internal_to_notes.rb'
TypeError: superclass mismatch for class AddInternalToNotes
from db/migrate/20220907124320_add_internal_to_notes.rb:3:in `<main>'
The reason we see it in this MR is probably because of a change that now loads database migrations earlier.
We should add a test or a Rubocop rule to detect and prevent this (search migrations having the same class name as database migrations). The existing clash we should fix be renaming one of the migrations.