-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include a nodegroup's graph as nodegroup.graphid #11397
base: dev/8.0.x
Are you sure you want to change the base?
Changes from all commits
97ebabc
1f3bcc8
a366cc6
64bb786
303ba4b
9012775
8c88482
aa4b4e3
9bf43f3
70eee7a
01d3ff1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Generated by Django 4.2.15 on 2024-08-23 16:20 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("models", "9053_add_future_graphs"), | ||
] | ||
|
||
sql = """ | ||
UPDATE node_groups | ||
SET graphid = sub.graphid | ||
FROM ( | ||
SELECT DISTINCT ng.nodegroupid, n.graphid | ||
FROM nodes n | ||
JOIN node_groups ng ON n.nodegroupid = ng.nodegroupid | ||
) AS sub | ||
WHERE node_groups.nodegroupid = sub.nodegroupid; | ||
""" | ||
|
||
reverse_sql = """""" | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="nodegroup", | ||
name="graph", | ||
field=models.ForeignKey( | ||
blank=True, | ||
db_column="graphid", | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="models.graphmodel", | ||
), | ||
), | ||
migrations.RunSQL( | ||
sql, | ||
reverse_sql, | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -715,6 +715,9 @@ class NodeGroup(models.Model): | |
null=True, | ||
on_delete=models.CASCADE, | ||
) # Allows nodegroups within nodegroups | ||
graph = models.ForeignKey( | ||
GraphModel, db_column="graphid", blank=True, null=True, on_delete=models.CASCADE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, null=True doesn't really gel with on_delete=cascade, so if it's only here to support preexisting cruft data, and we already have a major version bump, maybe we just add a command to manage.py validate that deletes cruft nodegroups, and say you have to run that fix before upgrading to 8? WDYT? |
||
) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(NodeGroup, self).__init__(*args, **kwargs) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this blank=False in order to add some friction?