Multiple spec failures on index_vulnerability_feedback_on_merge_request_id index
Summary
There's multiple specs failing when trying to revert ee/db/migrate/20190301182031_add_merge_request_id_index_on_vulnerability_feedback.rb
. It can't be reverted because the index added in the migration is required for a FK constraint.
Error message example
Mysql2::Error: Cannot drop index 'index_vulnerability_feedback_on_merge_request_id': needed in a foreign key constraint: ALTER TABLE `vulnerability_feedback` DROP `merge_request_id`
There's also a static_analysis
failure related to this.
Possible fixes
Split the migration into two separate ones. Add the foreign key constraint in the first, then add the index in the second. That way, when reverting, we can remove the index first then the FK. Doing it the other way around violates referential integrity constraints and errors out.
Edited by Matija Čupić