@@ -0,0 +1,1033 @@
+# Generated by Django 2.2.24 on 2022-06-08 13:13%0A%0Afrom django.db import migrations%0A%0Adef create_teams(apps, schema_editor):%0A    PeriodParticipant = apps.get_model('time_based', 'PeriodParticipant')%0A    Team = apps.get_model('activities', 'Team')%0A%0A    status_map = %7B%0A        'new': 'new',%0A        'accepted': 'open',%0A        'rejected': 'cancelled',%0A        'cancelled': 'cancelled',%0A        'withdrawn': 'withdrawn',%0A        'stopped': 'cancelled'%0A    %7D%0A%0A%0A    for participant in PeriodParticipant.objects.filter(%0A        team=None,%0A        activity__team_activity='teams'%0A    ):%0A        team, _created = Team.objects.get_or_create(%0A            activity=participant.activity, %0A            owner=participant.user, %0A            status=status_map.get(participant.status, 'open')%0A        )%0A        participant.team = team%0A%0A        participant.save()%0A%0A%0Aclass Migration(migrations.Migration):%0A%0A    dependencies = %5B%0A        ('activities', '0056_auto_20220406_1220'),%0A    %5D%0A%0A    operations = %5B%0A        migrations.RunPython(create_teams)%0A    %5D%0A

add migration that adds a team to existing team participants