diff --git a/arches/app/models/migrations/11613_node_nodegroup_root_matches_nodegroup.py b/arches/app/models/migrations/11613_node_nodegroup_root_matches_nodegroup.py new file mode 100644 index 0000000000..13b9beccce --- /dev/null +++ b/arches/app/models/migrations/11613_node_nodegroup_root_matches_nodegroup.py @@ -0,0 +1,20 @@ +# Generated by Django 5.1.3 on 2024-11-13 19:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("models", "11613_add_node_constraints"), + ] + + operations = [ + migrations.AddConstraint( + model_name="node", + constraint=models.CheckConstraint( + condition=models.Q(("nodegroup_root_id", models.F("nodegroup_id"))), + name="nodegroup_root_matches_nodegroup", + ), + ), + ] diff --git a/arches/app/models/models.py b/arches/app/models/models.py index 3b84bca9f5..95bd01b2be 100644 --- a/arches/app/models/models.py +++ b/arches/app/models/models.py @@ -947,6 +947,10 @@ class Meta: condition=Q(istopnode=True) | Q(nodegroup_root__isnull=False), name="has_nodegroup_root_or_istopnode", ), + models.CheckConstraint( + condition=Q(nodegroup_root_id=models.F("nodegroup_id")), + name="nodegroup_root_matches_nodegroup", + ), ]