Ensure a work item is assigned to all issues on before_validation
What does this MR do and why?
We are going to validate a NOT NULL
constraint on the issues.work_item_type_id
column. This callback makes sure we always assign a type when not explicitly set. Issue update and create service do not rely on this callback, but there are many other places that might still need this. We can consider removing the callback after the constraint has been validated.
Every other place in the codebase that creates new issues without running callbacks and validations has already been changed to include a work item type id as part of the create attributes.
How to set up and validate locally
You can use the console to test the callback bin/rails c
Try creating a new issue and you'll see that a work_item_type_id
is assigned after creation even if you don't specify a work item type. Be sure to test using work_item_type_id
since work_item_type
currently returns a fallback if no value was present in the DB. This will also be removed after we backfill and validate the not null contraint
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #338003 (closed)