# Generated by Django 2.2.10 on 2020-05-28 09:11

from django.db import migrations, models


def populate_guardian_email(apps, schema_editor):
    Guardian = apps.get_model("users", "Guardian")
    for guardian in Guardian.objects.filter(email=""):
        guardian.email = guardian.user.email
        guardian.save(update_fields=("email",))


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0005_add_guardian_email"),
    ]

    operations = [
        migrations.RunPython(populate_guardian_email, migrations.RunPython.noop),
        migrations.AlterField(
            model_name="guardian",
            name="email",
            field=models.EmailField(
                blank=True,
                help_text="If left blank, will be populated with the user's email.",
                max_length=254,
                verbose_name="email address",
            ),
        ),
    ]
