Skip to content

[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

  1. Remove uniqueness check from "namespace_id" for Segment model
  2. Add "display_namespace_id" to Segment model. It should represent the group where segment should be displayed on.
  3. Add "namespace_id" to Snapshot model, namespace_id must be unique. Fill namespace_id with a namespace of segment_id
  4. For given group adoption table query should be something like Segment.where(display_namespace: group)
  5. segment#snapshots should be association on segments.namespace_id == snapshot.namespace_id
  6. Later on drop segment_id association on Snapshot.
  7. If a segment is deleted Snapshots should NOT be deleted. Basically snapshots should be never deleted.
Edited by Pavel Shutsin