# Generated by Django 4.1.8 on 2023-04-17 07:22

import django.db.models.deletion
from django.db import migrations, models


def migrate_script(apps, schema_editor):
    User = apps.get_model("authentication", "User")
    from wbcore.contrib.directory.models import Person

    for user in User.objects.filter(profile__isnull=True):
        user.profile_id = Person.get_or_create_with_user(user).id
        user.save()


class Migration(migrations.Migration):
    dependencies = [
        ("directory", "0002_auto_20230414_1553"),
        ("authentication", "0002_profile"),
    ]

    operations = [
        migrations.AlterField(
            model_name="user",
            name="profile",
            field=models.OneToOneField(
                default=None,
                on_delete=django.db.models.deletion.PROTECT,
                related_name="user_account",
                to="directory.person",
            ),
            preserve_default=False,
        ),
    ]
