Add trigger to update issues correct_work_item_type_id
What does this MR do and why?
Before we introduced a trigger on insert or update
but we didn't account for updates of issues records
that don't change the work_item_type_id
column. This
new trigger should be executed for every update
and set the correct value only if it wasn't updated
before.
With this trigger, it should be safe to add a NOT VALID
FK on issues.correct_work_item_type_id
. This is a second attempt to add the FK as before it caused an incident when updating issue records gitlab-com/gl-infra/production#18692 (closed)
Timeline of migrations
- Add first trigger, and FK - !167510 (merged)
- enqeue the background migration - !167972 (merged)
- drop FK due to incident - !168741 (merged)
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.
Related to #493974 (closed)
Edited by Mario Celi