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

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


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, verbose_name='city')),
                ('country', django_countries.fields.CountryField(max_length=2, verbose_name='country')),
                ('opened_in', models.IntegerField(verbose_name='opened in')),
            ],
            options={
                'ordering': ['name'],
                'verbose_name': 'Circuit',
                'verbose_name_plural': 'Circuits',
            },
        ),
        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, verbose_name='full name')),
                ('country', django_countries.fields.CountryField(blank=True, default=None, max_length=2, null=True, verbose_name='country')),
                ('slug', models.SlugField(blank=True, default=None, null=True)),
            ],
            options={
                'ordering': ['name'],
                'verbose_name': 'Competition',
                'verbose_name_plural': 'Competitions',
            },
        ),
        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')),
            ],
        ),
        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, verbose_name='last name')),
                ('first_name', models.CharField(max_length=25, verbose_name='first name')),
                ('year_of_birth', models.IntegerField(blank=True, null=True, verbose_name='year of birth')),
                ('country', django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='country')),
            ],
            options={
                'ordering': ['last_name', 'first_name'],
                'verbose_name': 'Driver',
                'verbose_name_plural': 'Drivers',
            },
            bases=(models.Model, driver27.stats.AbstractStreakModel),
        ),
        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, verbose_name='country')),
                ('first_held', models.IntegerField(blank=True, null=True, verbose_name='first held')),
                ('competitions', models.ManyToManyField(default=None, related_name='grands_prix', to='driver27.Competition', verbose_name='competitions')),
                ('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', verbose_name='default circuit')),
            ],
            options={
                'ordering': ['name'],
                'verbose_name': 'Grand Prix',
                '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(verbose_name='round')),
                ('date', models.DateField(blank=True, default=None, null=True, verbose_name='date')),
                ('alter_punctuation', models.CharField(blank=True, choices=[('double', 'Double'), ('half', 'Half')], default=None, max_length=6, null=True, verbose_name='alter punctuation')),
                ('circuit', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='races', to='driver27.Circuit', verbose_name='circuit')),
            ],
            options={
                'ordering': ['season', 'round'],
                'verbose_name': 'Race',
                'verbose_name_plural': 'Races',
            },
        ),
        migrations.CreateModel(
            name='Result',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('qualifying', swapfield.fields.SwapIntegerField(blank=True, default=None, null=True, unique_for_fields=['race'], verbose_name='qualifying')),
                ('finish', swapfield.fields.SwapIntegerField(blank=True, default=None, null=True, unique_for_fields=['race'], verbose_name='finish')),
                ('retired', models.BooleanField(default=False, verbose_name='retired')),
                ('wildcard', models.BooleanField(default=False, verbose_name='wildcard')),
                ('comment', models.CharField(blank=True, default=None, max_length=250, null=True, verbose_name='comment')),
                ('points', models.IntegerField(blank=True, default=0, null=True, verbose_name='points')),
                ('race', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='results', to='driver27.Race', verbose_name='race')),
            ],
            options={
                'ordering': ['race__season', 'race__round', 'finish', 'qualifying'],
                'verbose_name': 'Result',
                'verbose_name_plural': 'Results',
            },
        ),
        migrations.CreateModel(
            name='Season',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('year', models.IntegerField(verbose_name='year')),
                ('rounds', models.IntegerField(blank=True, default=None, null=True, verbose_name='rounds')),
                ('punctuation', models.CharField(default=None, max_length=20, null=True, verbose_name='punctuation')),
                ('competition', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons', to='driver27.Competition', verbose_name='competition')),
            ],
            options={
                'ordering': ['year', 'competition__name'],
                'verbose_name': 'Season',
                'verbose_name_plural': 'Seasons',
            },
        ),
        migrations.CreateModel(
            name='Seat',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('driver', models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='seats', to='driver27.Driver', verbose_name='driver')),
            ],
            options={
                'ordering': ['driver__last_name', 'team'],
                'verbose_name': 'Seat',
                'verbose_name_plural': 'Seats',
            },
        ),
        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.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, verbose_name='full name')),
                ('country', django_countries.fields.CountryField(blank=True, max_length=2, null=True, verbose_name='country')),
                ('competitions', models.ManyToManyField(related_name='teams', through='driver27.CompetitionTeam', to='driver27.Competition', verbose_name='competitions')),
            ],
            options={
                'ordering': ['name'],
                'verbose_name': 'Team',
                'verbose_name_plural': 'Teams',
            },
            bases=(models.Model, driver27.stats.AbstractStreakModel),
        ),
        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, verbose_name='sponsor name')),
                ('season', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='teams_season', to='driver27.Season', verbose_name='season')),
                ('team', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='seasons_team', to='driver27.Team', verbose_name='team')),
            ],
            options={
                'verbose_name': 'Team Season',
                'verbose_name_plural': 'Teams Season',
            },
            bases=(models.Model, driver27.stats.AbstractStreakModel, driver27.stats.SeasonStatsModel),
        ),
        migrations.AddField(
            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.AddField(
            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.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.AddField(
            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.AddField(
            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.AddField(
            model_name='driver',
            name='teams',
            field=models.ManyToManyField(related_name='drivers', through='driver27.Seat', to='driver27.Team', verbose_name='teams'),
        ),
        migrations.AddField(
            model_name='competitionteam',
            name='team',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='periods', to='driver27.Team', verbose_name='team'),
        ),
        migrations.CreateModel(
            name='SeatsSeason',
            fields=[
            ],
            options={
                'verbose_name': 'Seats by season',
                'proxy': True,
                'verbose_name_plural': 'Seats by season',
                'indexes': [],
            },
            bases=('driver27.season',),
        ),
        migrations.AlterUniqueTogether(
            name='teamseason',
            unique_together=set([('season', 'team')]),
        ),
        migrations.AlterUniqueTogether(
            name='seat',
            unique_together=set([('team', 'driver')]),
        ),
        migrations.AlterUniqueTogether(
            name='season',
            unique_together=set([('year', 'competition')]),
        ),
        migrations.AlterUniqueTogether(
            name='result',
            unique_together=set([('race', 'seat')]),
        ),
        migrations.AlterUniqueTogether(
            name='race',
            unique_together=set([('season', 'round')]),
        ),
        migrations.AlterUniqueTogether(
            name='driver',
            unique_together=set([('last_name', 'first_name')]),
        ),
        migrations.AlterUniqueTogether(
            name='competitionteam',
            unique_together=set([('team', 'competition', 'from_year', 'until_year')]),
        ),
    ]
