Fix orphaned and missing work item parent links
What does this MR do and why?
Related issue: #465459 (closed)
Fix orphaned work item parent links
When moving an issue we do the following:
- We close the initial issue
A
on the old project. - We create a new issue
B
on the new project. - We change the
epic_issues
relationship and update theepic_issues.issue_id
to the ID of issueB
.
We missed to sync step 3 to work_item_parent_links
, and in addition to
that, to update the namespace_id
on work_item_parent_links
.
epic_issues
is still the SSoT and contains all epic<>issues
relationships we need to sync. However, we have orphaned
work_item_parent_links
with the wrong work_item_id
and
namespace_id
.
This is what we need to fix as part of the migration. Since the wrong syncing logic was never shipped to self managed instances, we can run the migration only on SaaS.
Changelog: fixed EE: true
Queries
I used the following query to find affected epics:
select
epic_issues.epic_id
from
epic_issues
LEFT JOIN work_item_parent_links ON work_item_parent_links.work_item_id = epic_issues.issue_id
WHERE
work_item_parent_links.work_item_id IS NULL
LIMIT
10;
- Missing work item parent links
- Orphaned (to delete) work item parent links
Before
issues
id | project_namespace_id | Note |
---|---|---|
1 | 1 | Old, closed issue |
2 | 2 | New, moved issue |
epic_issues
issue_id | epic_id |
---|---|
2 | 1 |
work_item_parent_links
work_item_id | namespace_id |
---|---|
1 | 1 |
After
epic_issues (stays the same)
issue_id | epic_id |
---|---|
2 | 1 |
work_item_parent_links
work_item_id | namespace_id |
---|---|
2 | 2 |
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.