Skip to content

Commit

Permalink
fix migration, since get_or_create doesn't seem to set the name
Browse files Browse the repository at this point in the history
  • Loading branch information
longhotsummer committed Sep 4, 2024
1 parent 5693647 commit 324efc1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions peachjam/migrations/0152_backfill_natures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ def forwards(apps, schema_editor):
("journal", "journal", "Journal"),
]
for doc_type, nature, name in DOC_TYPES:
nature = DocumentNature.objects.get_or_create(
code=nature, defaults={"name": name}
)[0]
nature = DocumentNature.objects.get_or_create(code=nature)[0]
# get_or_create with defaults={name: name} doesn't seem to work
if not nature.name:
nature.name = name
nature.save()

# run raw SQL to do the update for this doc_type and nature id
with schema_editor.connection.cursor() as cursor:
Expand Down

0 comments on commit 324efc1

Please sign in to comment.