# Generated by Django 2.2.5 on 2019-10-08 16:04

from django.db import migrations

from agir.system_pay.utils import clean_system_pay_data


def remove_sensitive_information(apps, schema):
    SystemPayTransaction = apps.get_model("system_pay", "SystemPayTransaction")

    for sp in SystemPayTransaction.objects.iterator():
        try:
            sp.webhook_calls = [clean_system_pay_data(c) for c in sp.webhook_calls]
            sp.save()
        except (TypeError, AttributeError):
            pass


class Migration(migrations.Migration):
    dependencies = [("system_pay", "0006_systempaytransaction_is_refund")]

    operations = [
        migrations.RunPython(
            code=remove_sensitive_information,
            reverse_code=migrations.RunPython.noop,
            elidable=True,
        )
    ]
