# Generated by Django 4.2.19 on 2025-03-14 16:45

from django.db import migrations


def create_profiles(apps, schema_editor):
    User = apps.get_model("auth", "User")
    UserProfile = apps.get_model("agenda_culturel", "UserProfile")

    for instance in User.objects.all():
        if not hasattr(instance, "userprofile"):
            UserProfile.objects.create(user=instance)
            instance.userprofile.is_moderation_expert = True

        instance.userprofile.save()


def create_profiles_backward(apps, schema_editor):
    pass


class Migration(migrations.Migration):

    dependencies = [
        ("agenda_culturel", "0156_alter_userprofile_options"),
    ]

    operations = [
        migrations.RunPython(
            code=create_profiles,
            reverse_code=create_profiles_backward,
        ),
    ]
