Safer migration runpython function

This commit is contained in:
Mouse Reeve 2021-02-10 17:30:26 -08:00
parent e918ddf526
commit 3aa7f8afe0

View file

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