# Generated by Django 2.1.5 on 2019-03-03 13:11

from django.db import migrations, transaction


def create_notifications_settings(apps, schema_editor):
    User = apps.get_model('openbook_auth', 'User')
    UserNotificationsSettings = apps.get_model('openbook_auth', 'UserNotificationsSettings')
    with transaction.atomic():
        for user in User.objects.all():
            UserNotificationsSettings.objects.create(user=user)


def delete_notifications_settings(apps, schema_editor):
    User = apps.get_model('openbook_auth', 'User')
    UserNotificationsSettings = apps.get_model('openbook_auth', 'UserNotificationsSettings')
    with transaction.atomic():
        for user in User.objects.all():
            UserNotificationsSettings.objects.get(user=user).delete()


class Migration(migrations.Migration):
    dependencies = [
        ('openbook_auth', '0023_usernotificationssettings'),
    ]

    operations = [
        migrations.RunPython(create_notifications_settings, reverse_code=delete_notifications_settings),
    ]
