Skip to content

Commit

Permalink
include UPDATE query in migration, rename filename for issue number, re
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Aug 23, 2024
1 parent 303ba4b commit 9012775
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ class Migration(migrations.Migration):
("models", "10804_core_search_filters"),
]

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",
Expand All @@ -22,4 +35,8 @@ class Migration(migrations.Migration):
to="models.graphmodel",
),
),
migrations.RunSQL(
sql,
reverse_sql,
),
]

0 comments on commit 9012775

Please sign in to comment.