Skip to content

Ensure that requirement belongs to same project of work item

What does this MR do and why?

Add model validation not allowing requirements to belong to a different project from its work item.

Technical debt described at #377474 (closed)

There is no indication that this is happening in production or self-managed instances, but I think it is still worth having this validation at least at the model level as we cannot remove project_id column from requirements table.

Production check

gitlabhq_production=> SELECT COUNT(*) FROM requirements 
gitlabhq_production->   INNER JOIN issues ON issues.id = requirements.issue_id
gitlabhq_production->   WHERE issues.project_id != requirements.project_id \g
 count 
-------
     0
(1 row)

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Felipe Cardozo

Merge request reports

Loading