# Generated by Django 4.2 on 2023-08-28 06:46

from django.apps.registry import Apps
from django.contrib.auth import get_user_model
from django.db import migrations


def populate_notification_preference(apps: Apps, schema_editor):
    UserNotificationPreference = apps.get_model("django_drf_otp", "UserNotificationPreference")
    User = get_user_model()

    users = User.objects.values_list("pk", flat=True)
    for user_id in users:
        UserNotificationPreference.objects.get_or_create(user_id=user_id, notification_type="email")


class Migration(migrations.Migration):
    dependencies = [
        ("django_drf_otp", "0001_initial"),
    ]

    operations = [
        migrations.RunPython(code=populate_notification_preference, reverse_code=migrations.RunPython.noop),
    ]
