[DevOps Adoption] Store segment target group in DB
Summary
After introduction of group-level DevOps Adoption pages a lot more user can create\delete Segments for their groups\subgroups. Currently we don't store segment author nor the place where we created the segment. For example:
-
Given Group X is enabled in the table of root group R
-
When user visits adoption page for group X they see data for group X
-
When user visits adoption page for root group R they see data for group X
-
Given Group X is enabled in the table of root group R
-
When user visits adoption page for group X and deletes group X from the table
-
And user visits adoption page for root group R they won't see data for group X anymore
I think it can be a source of confusion, and to handle that we need to store particular group where we enabled the feature for group X.
Proposal
When user deletes a segment from a group X then it should disappear from group X page only and should keep any existing adoption tables of parent groups untouched.
Technical proposal
- Remove uniqueness check from "namespace_id" for Segment model
- Add "display_namespace_id" to Segment model. It should represent the group where segment should be displayed on.
- Add "namespace_id" to Snapshot model, namespace_id must be unique. Fill
namespace_id
with a namespace of segment_id - For given group adoption table query should be something like
Segment.where(display_namespace: group)
-
segment#snapshots
should be association onsegments.namespace_id == snapshot.namespace_id
- Later on drop
segment_id
association on Snapshot. - If a segment is deleted Snapshots should NOT be deleted. Basically snapshots should be never deleted.