Skip to content

Investigate if we need to add legacy_epic_id to issues

With !145124 (merged) we added tmp_epic_id to the issues table to avoid creating duplicated records when backfilling epics to the issues table.

Thinking forward about the delegation workstream we will on the WorkItem / issues side always need to query the epics table to get the correlating Epic to perform the UNION queries for shared tables. Example when getting all notes:

$epic_id = SELECT id FROM epics where epics.issue_id = $issue_id;

SELECT * from notes where issuable_id = $issue_id AND issuable_type = 'issues'
UNION
SELECT * from notes where issuable_id = epics.id AND issuable_type = 'epics';

If we'd however use the tmp_epic_id that we store when backfilling, we could remove that need and query directly:

SELECT * from notes where issuable_id = $issue.id AND issuable_type = 'issues'
UNION
SELECT * from notes where issuable_id = $issus.tmp_epic_id AND issuable_type = 'epics';

Of course, instead of the name tmp_epic_id we should name it to something meaningful like legacy_epic_id.

We should investigate if it makes sense from a performance perspective to not query the epics table all the time. All it would require a rename of the column from tmp_epic_id to legacy_epic_id which should be fine as it is an Ignored Column already.

We will see if we need it after working on Workstream 4: Read shared associations from Leg... (&12751 - closed)

Edited by Nicolas Dular