Merge pull request #613 from mouse-reeve/migration-fix

Safer migration runpython function
This commit is contained in:
Mouse Reeve 2021-02-10 18:31:40 -08:00 committed by GitHub
commit bf941f1507
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,7 +10,10 @@ def set_user(app_registry, schema_editor):
shelfbook = app_registry.get_model('bookwyrm', 'ShelfBook')
for item in shelfbook.objects.using(db_alias).filter(user__isnull=True):
item.user = item.shelf.user
item.save(broadcast=False)
try:
item.save(broadcast=False)
except TypeError:
item.save()
class Migration(migrations.Migration):