# Generated by Django 2.2.19 on 2021-10-14 09:01

from django.db import migrations
from django.utils.timezone import now


def fill_cancelled_date(apps, schema_editor):
    DirectDebit = apps.get_model('pz', 'DirectDebit')
    DirectDebit.objects.filter(is_cancelled=True).update(
        cancelled_at=now()
    )


def fill_is_cancelled(apps, schema_editor):
    DirectDebit = apps.get_model('pz', 'DirectDebit')
    DirectDebit.objects.exclude(cancelled_at=None).update(
        is_cancelled=True
    )


class Migration(migrations.Migration):

    dependencies = [
        ('pz', '0007_auto_20211014_1100'),
    ]

    operations = [
        migrations.RunPython(
            fill_cancelled_date,
            fill_is_cancelled
        )
    ]
