namespaces.traversal_ids check constraints
We can improve integrity of namespaces.traversal_ids
by adding custom database check constraints.
These constraints will complement work completed in !52854 (merged).
The constraints are:
- ensure
traversal_ids[-1] == id
- ensure
traversal_ids[-2] == parent_id
These constraints do not prevent all errors, but will help to prevent some class of errors. Adding full foreign key constraint checks on each item in traversal_ids
is deemed too expensive.
While working here it's also well worth pondering the issues raised in !56296 (comment 536791028) to ensure a solution to this issue will also fix concerns raised in that thread.
Some previous work on these constraints has been saved in a branch at https://gitlab.com/gitlab-org/gitlab/-/tree/300377-traversal-ids-column-sync-with-constraints
Edited by Alex Pooley