Ensure suggestions sharding key is set at the application level
What does this MR do and why?
This is part of the work needed for sharding the table suggestions (Re #550696):
| Tasks | MR |
|---|---|
|
|
|
|
|
|
|
|
Summary of changes
- Add a
before_validationcallback to setnamespace_idon create - Validate presence of
namespaceon create (unless the record is being imported) - Update
Suggestions::CreateServiceto setnamespace_idwhen creating a suggestion - Update specs to ensure the
namespace_idvalue is being set for these records (including during a project import)
To note: In Suggestion#ensure_namespace_id, we have to check for note.project.project_namespace_id because note.namespace_id (that table sharding key) might not be present yet. We do know that these kinds of notes belong to a project, so if the note is present, we can fetch the namespace via its project.
References
Related to #572849
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Edited by Eugenia Grieff