# Generated by Django 3.1.12 on 2021-06-22 11:17

from django.db import migrations, models, connection


def activity_pushed_to_push_status_field(apps, schema_editor):
    Activity = apps.get_model("activity", "Activity")
    Activity.objects.filter(pushed=True).update(push_status="S")


def activity_push_status_to_pushed_field(apps, schema_editor):
    Activity = apps.get_model("activity", "Activity")
    Activity.objects.exclude(push_status="U").update(pushed=True)


class Migration(migrations.Migration):
    dependencies = [
        ("activity", "0020_rename_recipient_reverse"),
    ]

    operations = [
        migrations.AddField(
            model_name="activity",
            name="push_status",
            field=models.CharField(
                choices=[
                    ("U", "Pas énvoyée au destinataire"),
                    ("S", "Envoyée au destinataire"),
                    ("I", "Cliquée par le destinataire"),
                ],
                default="U",
                max_length=1,
                verbose_name="Statut notification push",
            ),
        ),
        migrations.RunPython(
            activity_pushed_to_push_status_field,
            activity_push_status_to_pushed_field,
            atomic=True,
        ),
        migrations.RemoveField(
            model_name="activity",
            name="pushed",
        ),
    ]
