# Generated by Django 3.1.3 on 2022-05-30 09:05

from django.conf import settings
from django.db import migrations, models


def migrate_fkey_admin_to_m2m(apps, schema_editor):
    Team = apps.get_model('user', 'Team')
    all_teams = Team.objects.all()
    for team in all_teams:
        admin = team.admin
        if admin is None:
            continue
        team.admins.add(admin)
        team.save()


class Migration(migrations.Migration):

    dependencies = [
        ('user', '0003_team'),
    ]

    operations = [
        migrations.AddField(
            model_name='team',
            name='admins',
            field=models.ManyToManyField(blank=True, related_name='_team_admins_+', to=settings.AUTH_USER_MODEL),
        ),
        migrations.RunPython(migrate_fkey_admin_to_m2m),
        migrations.RemoveField(
            model_name='team',
            name='admin',
        ),
    ]
