-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf68f62
commit cb99670
Showing
9 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Generated by Django 5.1.3 on 2024-11-11 07:27 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("models", "10437_node_alias_not_null"), | ||
] | ||
|
||
def set_nodegroup_root(apps, schema_editor): | ||
Node = apps.get_model("models", "Node") | ||
all_but_top_nodes = Node.objects.exclude(istopnode=True) | ||
for node in all_but_top_nodes: | ||
assert node.nodegroup_id is not None, f"Missing nodegroup for {node!r}" | ||
node.nodegroup_root_id = node.nodegroup_id | ||
Node.objects.bulk_update(all_but_top_nodes, ["nodegroup_root_id"]) | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="node", | ||
name="nodegroup_root", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="sibling_nodes", | ||
related_query_name="sibling_node", | ||
to="models.node", | ||
), | ||
), | ||
migrations.RunPython(set_nodegroup_root, migrations.RunPython.noop), | ||
] |
33 changes: 33 additions & 0 deletions
33
arches/app/models/migrations/10439_add_node_constraints.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 5.1.3 on 2024-11-11 07:53 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("models", "10438_node_nodegroup_root"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddConstraint( | ||
model_name="node", | ||
constraint=models.CheckConstraint( | ||
condition=models.Q( | ||
("istopnode", True), ("nodegroup__isnull", False), _connector="OR" | ||
), | ||
name="has_nodegroup_or_istopnode", | ||
), | ||
), | ||
migrations.AddConstraint( | ||
model_name="node", | ||
constraint=models.CheckConstraint( | ||
condition=models.Q( | ||
("istopnode", True), | ||
("nodegroup_root__isnull", False), | ||
_connector="OR", | ||
), | ||
name="has_nodegroup_root_or_istopnode", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters