# Generated by Django 3.1.7 on 2021-04-06 16:05

from django.db import migrations
from django_scopes import scopes_disabled


def migrate_no_group_superusers(apps, schema_editor):
    with scopes_disabled():
        User = apps.get_model('auth', 'User')
        Groups = apps.get_model('auth', 'Group')

        for u in User.objects.filter(is_superuser=True).all():
            if u.groups.count() == 0:
                u.groups.add(Groups.objects.get(name='admin'))


class Migration(migrations.Migration):

    dependencies = [
        ('cookbook', '0117_space_max_recipes'),
    ]

    operations = [
        migrations.RunPython(migrate_no_group_superusers),
    ]
