opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
148 stars 7 forks source link

feature: Be able to use an hierarchical Parent/Ancestor as uniqueness_constraint #3682

Open BeArchiTek opened 2 weeks ago

BeArchiTek commented 2 weeks ago

Component

API Server / GraphQL

Describe the Feature Request

As an user I would like to use any Parent of an hierarchical node as uniqueness_constraint (right now it’s not possible cause Parent, is not a mandatory field)

Describe the Use Case

I want to define the uniqueness of a node base on its Parent

Use case 1 A Rack name is unique on a Site

Use case 2 A Site short name is unique in a country

Additional Information

It could be indirectly cover by compute field if we consider some of those restriction as read_only field, computed from 2 others attributes and/or relationship

wvandeun commented 2 weeks ago

I actually think we should split this up in 2 different issues

define uniqueness constraint to any level in a hierarchy for a node that has a relation to a hierarchical node

We define the following location hierarchy (Site > Building). We have a device node that has a relation to a building. However we need a device name to be unique within a site. Hence we want to define a unique constraint on the name of the device node and the second level of the location hierarchy.

define uniqueness constraint for a hierarchical node on any ancestor in the hierarchy

Given the following location hierarchy (Country > Site). A site name should be unique within a country, so we want to define a uniqueness constraint on a site name and country. This is currently not possible because a parent is not a required relationship.