Requeue backfilling of work item data
What does this MR do and why?
Related issues:
This re-syncs related_epic_links to issue_links,
epic_issues to work_item_parent_links, and epics.parent_id
to work_item_parent_links.
We need to re-sync the relationships because we found inconsistent data in self managed instances and also fixed a bug related to importing epics !170786 (merged) which could lead to these inconsistencies.
Changelog: fixed
References
Please include cross links to any resources that are relevant to this MR This will give reviewers and future readers helpful context to give an efficient review of the changes introduced.
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
Before running the migration
Manipulate your instance by removing a few records:
bin/rails c
# Destroy a related link
related_epic_link = Epic::RelatedEpicLink.first
WorkItems::RelatedWorkItemLink.where(source_id: related_epic_link.source.work_item.id).first.destroy!
# Destroy an epic-epic (work item) relationship
epic = Epic.where.not(parent_id: nil).first
WorkItems::ParentLink.where(work_item_id: epic.issue_id).first.destroy!
# Destroy an epic-issue (work item) relationship
epic_issue = EpicIssue.first
WorkItems::ParentLink.where(work_item_id: epic_issue.issue_id).first.destroy!
Run the migration
Keep the console open
bin/rails migrate
Check the data gain
#=> should return the records again
WorkItems::RelatedWorkItemLink.where(source_id: related_epic_link.source.work_item.id)
WorkItems::ParentLink.where(work_item_id: epic.issue_id)
WorkItems::ParentLink.where(work_item_id: epic_issue.issue_id)