Remove one block type relationship from issue links
Issues can block others with two relationship types, { TYPE_BLOCKS => 1, TYPE_IS_BLOCKED_BY => 2}
:
source_issue | block_type | target_issue |
---|---|---|
issue_1 | TYPE_BLOCKS | issue_2 |
issue_3 | TYPE_IS_BLOCKED_BY | issue_1 |
On the example above issue_1
is blocking two other issues using two different types of block.
The extra relation type adds complexity when querying for blocking/blocked issues as can be seen on IssueLink
class.
If possible we should consider using just one kind of blocking type to make queries simpler and a bit faster.
We will still be able to identify if an issue is blocked
or blocking
using the target_id
and source_id
keys.
This task will need migrations. We can get rid of the relation that has less records on database, which is this case is
We can migrate records with TYPE_BLOCKS => 1
link_type = 2
to have link_type = 1
and stop saving records with link_type = 2
:
gitlabhq_production=> SELECT COUNT(*) FROM issue_links WHERE link_type = 1 \g
count
-------
10410
(1 row)
gitlabhq_production=> SELECT COUNT(*) FROM issue_links WHERE link_type = 2 \g
count
-------
26218
(1 row)
For more context check the discussion on !34665 (comment 365697703)