From 324efc1a156d86a7ce29572fd6484f9c82757186 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Wed, 4 Sep 2024 12:46:08 +0200 Subject: [PATCH] fix migration, since get_or_create doesn't seem to set the name --- peachjam/migrations/0152_backfill_natures.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/peachjam/migrations/0152_backfill_natures.py b/peachjam/migrations/0152_backfill_natures.py index 4906dcea8..b40680833 100644 --- a/peachjam/migrations/0152_backfill_natures.py +++ b/peachjam/migrations/0152_backfill_natures.py @@ -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: