From 946182f1fef54f72f3498900acfc659765f60ad2 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 26 Mar 2017 15:06:45 -0300 Subject: [PATCH] Simpler migration revert --- kfet/migrations/0049_remove_checkout.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kfet/migrations/0049_remove_checkout.py b/kfet/migrations/0049_remove_checkout.py index 8328c9c4..d2eae10c 100644 --- a/kfet/migrations/0049_remove_checkout.py +++ b/kfet/migrations/0049_remove_checkout.py @@ -13,11 +13,9 @@ def adapt_operation_types(apps, schema_editor): def revert_operation_types(apps, schema_editor): Operation = apps.get_model("kfet", "Operation") - - for ope in Operation.objects.filter(type='edit'): - ope.type = 'deposit' if ope.amount > 0 else 'withdraw' - ope.is_checkout = False - ope.save() + edits = Operation.objects.filter(type='edit') + edits.filter(amount__gt=0).update(type='deposit') + edits.filter(amount__lte=0).update(type='withdraw') class Migration(migrations.Migration):