# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-10-24 20:58
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import django_countries.fields
import swapfield.fields


def populate_driver_in_seats(apps, schema_editor):
    Seat = apps.get_model("driver27", "Seat")
    for seat in Seat.objects.all():
        driver = seat.contender.driver
        seat.driver = driver
        seat.save()

def seats_contender_null(apps, schema_editor):
    Seat = apps.get_model("driver27", "Seat")
    for seat in Seat.objects.all():
        seat.contender = None
        seat.save()

def populate_competition_team(apps, schema_editor):
    Team = apps.get_model("driver27", "Team")
    CompetitionTeam = apps.get_model("driver27", "CompetitionTeam")
    for team in Team.objects.all():
        competitions = team.competitions.all()
        for competition in competitions:
            CompetitionTeam.objects.create(team=team, competition=competition)

def populate_fastest_lap(apps, schema_editor):
    Race = apps.get_model("driver27", "Race")
    for race in Race.objects.all():
        fastest = race.results.filter(fastest_lap=True).first()
        if fastest:
            race.fastest_car = fastest.seat
            race.save()

class Migration(migrations.Migration):

    replaces = [(b'driver27', '0001_initial'), (b'driver27', '0002_auto_20161103_0846'), (b'driver27', '0003_auto_20170204_2308'), (b'driver27', '0004_auto_20170204_2311'), (b'driver27', '0005_result_points'), (b'driver27', '0006_auto_20170529_2209'), (b'driver27', '0007_auto_20170529_2211'), (b'driver27', '0008_auto_20170529_2220'), (b'driver27', '0009_populate_driver_in_seats'), (b'driver27', '0010_seats_contender_null'), (b'driver27', '0011_remove_contender_teams'), (b'driver27', '0012_auto_20170529_2232'), (b'driver27', '0013_remove_seat_contender'), (b'driver27', '0014_auto_20170529_2320'), (b'driver27', '0015_auto_20170602_1447'), (b'driver27', '0016_driver_teams'), (b'driver27', '0017_auto_20170602_1526'), (b'driver27', '0018_populate_competition_team'), (b'driver27', '0019_remove_team_competitions'), (b'driver27', '0020_team_competitions'), (b'driver27', '0021_auto_20170602_1547'), (b'driver27', '0022_auto_20170602_1552'), (b'driver27', '0023_auto_20170602_1552'), (b'driver27', '0024_auto_20170602_1737'), (b'driver27', '0025_auto_20171022_2012'), (b'driver27', '0026_populate_fastest_race'), (b'driver27', '0027_auto_20171022_2021')]

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Circuit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True, verbose_name='circuit')),
                ('city', models.CharField(blank=True, max_length=100, null=True)),
                ('country', django_countries.fields.CountryField(max_length=2)),
                ('opened_in', models.IntegerField()),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Competition',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True, verbose_name='competition')),
                ('full_name', models.CharField(max_length=100, unique=True)),
                ('country', django_countries.fields.CountryField(blank=True, default=None, max_length=2, null=True)),
                ('slug', models.SlugField(blank=True, default=None, null=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Contender',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contenders', to='driver27.Competition')),
            ],
            options={
                'ordering': ['competition__name', 'driver__last_name', 'driver__first_name'],
            },
        ),
        migrations.CreateModel(
            name='Driver',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('last_name', models.CharField(max_length=50)),
                ('first_name', models.CharField(max_length=25)),
                ('year_of_birth', models.IntegerField()),
                ('country', django_countries.fields.CountryField(max_length=2)),
                ('competitions', models.ManyToManyField(related_name='drivers', through='driver27.Contender', to=b'driver27.Competition')),
            ],
            options={
                'ordering': ['last_name', 'first_name'],
            },
        ),
        migrations.CreateModel(
            name='GrandPrix',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True, verbose_name='grand prix')),
                ('country', django_countries.fields.CountryField(blank=True, default=None, max_length=2, null=True)),
                ('first_held', models.IntegerField(blank=True, null=True)),
                ('competitions', models.ManyToManyField(default=None, related_name='grands_prix', to=b'driver27.Competition')),
                ('default_circuit', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='default_to_grands_prix', to='driver27.Circuit')),
            ],
            options={
                'ordering': ['name'],
                'verbose_name_plural': 'grands prix',
            },
        ),
        migrations.CreateModel(
            name='Race',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('round', models.IntegerField()),
                ('date', models.DateField(blank=True, default=None, null=True)),
                ('alter_punctuation', models.CharField(blank=True, choices=[('double', 'Double'), ('half', 'Half')], default=None, max_length=6, null=True)),
                ('circuit', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.Circuit')),
                ('grand_prix', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.GrandPrix')),
            ],
            options={
                'ordering': ['season', 'round'],
            },
        ),
        migrations.CreateModel(
            name='Result',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qualifying', models.IntegerField(blank=True, default=None, null=True)),
                ('finish', models.IntegerField(blank=True, default=None, null=True)),
                ('fastest_lap', models.BooleanField(default=False)),
                ('retired', models.BooleanField(default=False)),
                ('wildcard', models.BooleanField(default=False)),
                ('comment', models.CharField(blank=True, default=None, max_length=250, null=True)),
                ('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='driver27.Race')),
            ],
            options={
                'ordering': ['race__season', 'race__round', 'finish', 'qualifying'],
            },
        ),
        migrations.CreateModel(
            name='Season',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('year', models.IntegerField()),
                ('rounds', models.IntegerField(blank=True, default=None, null=True)),
                ('punctuation', models.CharField(default=None, max_length=20, null=True)),
                ('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons', to='driver27.Competition')),
            ],
            options={
                'ordering': ['competition__name', 'year'],
            },
        ),
        migrations.CreateModel(
            name='Seat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('current', models.BooleanField(default=False)),
                ('contender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Contender')),
                ('seasons', models.ManyToManyField(blank=True, default=None, related_name='seats', to=b'driver27.Season')),
            ],
            options={
                'ordering': ['contender__driver__last_name', 'team'],
            },
        ),
        migrations.CreateModel(
            name='Team',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=75, unique=True, verbose_name='team')),
                ('full_name', models.CharField(max_length=200, unique=True)),
                ('country', django_countries.fields.CountryField(max_length=2)),
                ('competitions', models.ManyToManyField(related_name='teams', to=b'driver27.Competition')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='TeamSeason',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sponsor_name', models.CharField(blank=True, default=None, max_length=75, null=True)),
                ('season', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teams_season', to='driver27.Season')),
                ('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons_team', to='driver27.Team')),
            ],
            options={
                'verbose_name': 'Team Season',
                'verbose_name_plural': 'Teams Season',
            },
        ),
        migrations.AddField(
            model_name='seat',
            name='team',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Team'),
        ),
        migrations.AddField(
            model_name='season',
            name='teams',
            field=models.ManyToManyField(related_name='seasons', through='driver27.TeamSeason', to=b'driver27.Team'),
        ),
        migrations.AddField(
            model_name='result',
            name='seat',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='driver27.Seat'),
        ),
        migrations.AddField(
            model_name='race',
            name='season',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.Season'),
        ),
        migrations.AddField(
            model_name='contender',
            name='driver',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='career', to='driver27.Driver'),
        ),
        migrations.AddField(
            model_name='contender',
            name='teams',
            field=models.ManyToManyField(related_name='contenders', through='driver27.Seat', to=b'driver27.Team'),
        ),
        migrations.AlterUniqueTogether(
            name='teamseason',
            unique_together=set([('season', 'team')]),
        ),
        migrations.AlterField(
            model_name='seat',
            name='current',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterUniqueTogether(
            name='seat',
            unique_together=set([('team', 'contender')]),
        ),
        migrations.AlterUniqueTogether(
            name='season',
            unique_together=set([('year', 'competition')]),
        ),
        migrations.AlterField(
            model_name='result',
            name='fastest_lap',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterUniqueTogether(
            name='result',
            unique_together=set([('race', 'seat'), ('race', 'qualifying'), ('race', 'finish')]),
        ),
        migrations.AlterUniqueTogether(
            name='race',
            unique_together=set([('season', 'round')]),
        ),
        migrations.AlterUniqueTogether(
            name='driver',
            unique_together=set([('last_name', 'first_name')]),
        ),
        migrations.AlterUniqueTogether(
            name='contender',
            unique_together=set([('driver', 'competition')]),
        ),
        migrations.CreateModel(
            name='SeatsSeason',
            fields=[
            ],
            options={
                'verbose_name': 'Seats by season',
                'proxy': True,
                'verbose_name_plural': 'Seats by season',
            },
            bases=('driver27.season',),
        ),
        migrations.AlterModelOptions(
            name='circuit',
            options={'ordering': ['name'], 'verbose_name': 'Circuit', 'verbose_name_plural': 'Circuits'},
        ),
        migrations.AlterModelOptions(
            name='competition',
            options={'ordering': ['name'], 'verbose_name': 'Competition', 'verbose_name_plural': 'Competitions'},
        ),
        migrations.AlterModelOptions(
            name='contender',
            options={'ordering': ['competition__name', 'driver__last_name', 'driver__first_name'], 'verbose_name': 'Contender', 'verbose_name_plural': 'Contenders'},
        ),
        migrations.AlterModelOptions(
            name='driver',
            options={'ordering': ['last_name', 'first_name'], 'verbose_name': 'Driver', 'verbose_name_plural': 'Drivers'},
        ),
        migrations.AlterModelOptions(
            name='grandprix',
            options={'ordering': ['name'], 'verbose_name': 'Grand Prix', 'verbose_name_plural': 'Grands Prix'},
        ),
        migrations.AlterModelOptions(
            name='race',
            options={'ordering': ['season', 'round'], 'verbose_name': 'Race', 'verbose_name_plural': 'Races'},
        ),
        migrations.AlterModelOptions(
            name='result',
            options={'ordering': ['race__season', 'race__round', 'finish', 'qualifying'], 'verbose_name': 'Result', 'verbose_name_plural': 'Results'},
        ),
        migrations.AlterModelOptions(
            name='season',
            options={'ordering': ['competition__name', 'year'], 'verbose_name': 'Season', 'verbose_name_plural': 'Seasons'},
        ),
        migrations.AlterModelOptions(
            name='seat',
            options={'ordering': ['current', 'contender__driver__last_name', 'team'], 'verbose_name': 'Seat', 'verbose_name_plural': 'Seats'},
        ),
        migrations.AlterModelOptions(
            name='team',
            options={'ordering': ['name'], 'verbose_name': 'Team', 'verbose_name_plural': 'Teams'},
        ),
        migrations.AlterField(
            model_name='circuit',
            name='city',
            field=models.CharField(blank=True, max_length=100, null=True, verbose_name='city'),
        ),
        migrations.AlterField(
            model_name='circuit',
            name='country',
            field=django_countries.fields.CountryField(max_length=2, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='circuit',
            name='opened_in',
            field=models.IntegerField(verbose_name='opened in'),
        ),
        migrations.AlterField(
            model_name='competition',
            name='country',
            field=django_countries.fields.CountryField(blank=True, default=None, max_length=2, null=True, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='competition',
            name='full_name',
            field=models.CharField(max_length=100, unique=True, verbose_name='full name'),
        ),
        migrations.AlterField(
            model_name='contender',
            name='competition',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='contenders', to='driver27.Competition', verbose_name='competition'),
        ),
        migrations.AlterField(
            model_name='contender',
            name='driver',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='career', to='driver27.Driver', verbose_name='driver'),
        ),
        migrations.AlterField(
            model_name='contender',
            name='teams',
            field=models.ManyToManyField(related_name='contenders', through='driver27.Seat', to=b'driver27.Team', verbose_name='teams'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='competitions',
            field=models.ManyToManyField(related_name='drivers', through='driver27.Contender', to=b'driver27.Competition', verbose_name='competitions'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='country',
            field=django_countries.fields.CountryField(max_length=2, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='first_name',
            field=models.CharField(max_length=25, verbose_name='first name'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='last_name',
            field=models.CharField(max_length=50, verbose_name='last name'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='year_of_birth',
            field=models.IntegerField(verbose_name='year of birth'),
        ),
        migrations.AlterField(
            model_name='grandprix',
            name='competitions',
            field=models.ManyToManyField(default=None, related_name='grands_prix', to=b'driver27.Competition', verbose_name='competitions'),
        ),
        migrations.AlterField(
            model_name='grandprix',
            name='country',
            field=django_countries.fields.CountryField(blank=True, default=None, max_length=2, null=True, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='grandprix',
            name='default_circuit',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='default_to_grands_prix', to='driver27.Circuit', verbose_name='default circuit'),
        ),
        migrations.AlterField(
            model_name='grandprix',
            name='first_held',
            field=models.IntegerField(blank=True, null=True, verbose_name='first held'),
        ),
        migrations.AlterField(
            model_name='race',
            name='alter_punctuation',
            field=models.CharField(blank=True, choices=[('double', 'Double'), ('half', 'Half')], default=None, max_length=6, null=True, verbose_name='alter punctuation'),
        ),
        migrations.AlterField(
            model_name='race',
            name='circuit',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.Circuit', verbose_name='circuit'),
        ),
        migrations.AlterField(
            model_name='race',
            name='date',
            field=models.DateField(blank=True, default=None, null=True, verbose_name='date'),
        ),
        migrations.AlterField(
            model_name='race',
            name='grand_prix',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.GrandPrix', verbose_name='grand prix'),
        ),
        migrations.AlterField(
            model_name='race',
            name='round',
            field=models.IntegerField(verbose_name='round'),
        ),
        migrations.AlterField(
            model_name='race',
            name='season',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.Season', verbose_name='season'),
        ),
        migrations.AlterField(
            model_name='result',
            name='comment',
            field=models.CharField(blank=True, default=None, max_length=250, null=True, verbose_name='comment'),
        ),
        migrations.AlterField(
            model_name='result',
            name='fastest_lap',
            field=models.BooleanField(default=False, verbose_name='fastest lap'),
        ),
        migrations.AlterField(
            model_name='result',
            name='finish',
            field=models.IntegerField(blank=True, default=None, null=True, verbose_name='finish'),
        ),
        migrations.AlterField(
            model_name='result',
            name='qualifying',
            field=models.IntegerField(blank=True, default=None, null=True, verbose_name='qualifying'),
        ),
        migrations.AlterField(
            model_name='result',
            name='race',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='driver27.Race', verbose_name='race'),
        ),
        migrations.AlterField(
            model_name='result',
            name='retired',
            field=models.BooleanField(default=False, verbose_name='retired'),
        ),
        migrations.AlterField(
            model_name='result',
            name='seat',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='driver27.Seat', verbose_name='seat'),
        ),
        migrations.AlterField(
            model_name='result',
            name='wildcard',
            field=models.BooleanField(default=False, verbose_name='wildcard'),
        ),
        migrations.AlterField(
            model_name='season',
            name='competition',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons', to='driver27.Competition', verbose_name='competition'),
        ),
        migrations.AlterField(
            model_name='season',
            name='punctuation',
            field=models.CharField(default=None, max_length=20, null=True, verbose_name='punctuation'),
        ),
        migrations.AlterField(
            model_name='season',
            name='rounds',
            field=models.IntegerField(blank=True, default=None, null=True, verbose_name='rounds'),
        ),
        migrations.RemoveField(
            model_name='season',
            name='teams',
        ),
        migrations.AlterField(
            model_name='season',
            name='year',
            field=models.IntegerField(verbose_name='year'),
        ),
        migrations.AlterField(
            model_name='seat',
            name='contender',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Contender', verbose_name='contender'),
        ),
        migrations.AlterField(
            model_name='seat',
            name='current',
            field=models.BooleanField(default=False, verbose_name='current team'),
        ),
        migrations.AlterField(
            model_name='seat',
            name='seasons',
            field=models.ManyToManyField(blank=True, default=None, related_name='seats', to=b'driver27.Season', verbose_name='seasons'),
        ),
        migrations.AlterField(
            model_name='seat',
            name='team',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Team', verbose_name='team'),
        ),
        migrations.AlterField(
            model_name='team',
            name='competitions',
            field=models.ManyToManyField(related_name='teams', to=b'driver27.Competition', verbose_name='competitions'),
        ),
        migrations.AlterField(
            model_name='team',
            name='country',
            field=django_countries.fields.CountryField(max_length=2, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='team',
            name='full_name',
            field=models.CharField(max_length=200, unique=True, verbose_name='full name'),
        ),
        migrations.AlterField(
            model_name='teamseason',
            name='season',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teams_season', to='driver27.Season', verbose_name='season'),
        ),
        migrations.AlterField(
            model_name='teamseason',
            name='sponsor_name',
            field=models.CharField(blank=True, default=None, max_length=75, null=True, verbose_name='sponsor name'),
        ),
        migrations.AlterField(
            model_name='teamseason',
            name='team',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons_team', to='driver27.Team', verbose_name='team'),
        ),
        migrations.AlterField(
            model_name='result',
            name='finish',
            field=swapfield.fields.SwapIntegerField(blank=True, default=None, null=True, unique_for_fields=['race'], verbose_name='finish'),
        ),
        migrations.AlterField(
            model_name='result',
            name='qualifying',
            field=swapfield.fields.SwapIntegerField(blank=True, default=None, null=True, unique_for_fields=['race'], verbose_name='qualifying'),
        ),
        migrations.AddField(
            model_name='result',
            name='points',
            field=models.IntegerField(blank=True, default=0, null=True, verbose_name='points'),
        ),
        migrations.AlterUniqueTogether(
            name='result',
            unique_together=set([('race', 'seat')]),
        ),
        migrations.AlterModelOptions(
            name='seat',
            options={'ordering': ['contender__driver__last_name', 'team'], 'verbose_name': 'Seat', 'verbose_name_plural': 'Seats'},
        ),
        migrations.RemoveField(
            model_name='seat',
            name='current',
        ),
        migrations.AddField(
            model_name='seat',
            name='driver',
            field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Driver', verbose_name='driver'),
        ),
        migrations.AlterField(
            model_name='seat',
            name='contender',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Contender', verbose_name='contender'),
        ),
        migrations.RemoveField(
            model_name='seat',
            name='seasons',
        ),
        migrations.RunPython(
            code=populate_driver_in_seats,
        ),
        migrations.RunPython(
            code=seats_contender_null,
        ),
        migrations.RemoveField(
            model_name='contender',
            name='teams',
        ),
        migrations.AlterModelOptions(
            name='seat',
            options={'ordering': ['driver__last_name', 'team'], 'verbose_name': 'Seat', 'verbose_name_plural': 'Seats'},
        ),
        migrations.RemoveField(
            model_name='seat',
            name='contender',
        ),
        migrations.AlterUniqueTogether(
            name='seat',
            unique_together=set([('team', 'driver')]),
        ),
        migrations.AlterUniqueTogether(
            name='contender',
            unique_together=set([]),
        ),
        migrations.RemoveField(
            model_name='contender',
            name='competition',
        ),
        migrations.RemoveField(
            model_name='contender',
            name='driver',
        ),
        migrations.RemoveField(
            model_name='driver',
            name='competitions',
        ),
        migrations.DeleteModel(
            name='Contender',
        ),
        migrations.AlterField(
            model_name='driver',
            name='country',
            field=django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='country'),
        ),
        migrations.AlterField(
            model_name='driver',
            name='year_of_birth',
            field=models.IntegerField(blank=True, null=True, verbose_name='year of birth'),
        ),
        migrations.AddField(
            model_name='driver',
            name='teams',
            field=models.ManyToManyField(related_name='drivers', through='driver27.Seat', to=b'driver27.Team', verbose_name='teams'),
        ),
        migrations.CreateModel(
            name='CompetitionTeam',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('from_year', models.IntegerField(blank=True, default=None, null=True)),
                ('until_year', models.IntegerField(blank=True, default=None, null=True)),
                ('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='periods', to='driver27.Competition', verbose_name='competition')),
                ('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='periods', to='driver27.Team', verbose_name='team')),
            ],
        ),
        migrations.AlterUniqueTogether(
            name='competitionteam',
            unique_together=set([('team', 'competition', 'from_year', 'until_year')]),
        ),
        migrations.RunPython(
            code=populate_competition_team,
        ),
        migrations.RemoveField(
            model_name='team',
            name='competitions',
        ),
        migrations.AddField(
            model_name='team',
            name='competitions',
            field=models.ManyToManyField(related_name='teams', through='driver27.CompetitionTeam', to=b'driver27.Competition', verbose_name='competitions'),
        ),
        migrations.AlterUniqueTogether(
            name='seat',
            unique_together=set([('team', 'driver')]),
        ),
        migrations.CreateModel(
            name='SeatPeriod',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('from_year', models.IntegerField(blank=True, default=None, null=True)),
                ('until_year', models.IntegerField(blank=True, default=None, null=True)),
                ('seat', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='periods', to='driver27.Seat')),
            ],
        ),
        migrations.AlterField(
            model_name='team',
            name='country',
            field=django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='country'),
        ),
        migrations.AddField(
            model_name='race',
            name='fastest_car',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fastest_in', to='driver27.Seat'),
        ),
        migrations.RunPython(
            code=populate_fastest_lap,
        ),
        migrations.RemoveField(
            model_name='result',
            name='fastest_lap',
        ),
    ]
