# Generated by Django 2.0.5 on 2018-06-16 10:10

import django.core.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('crews', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Airplane',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('registration_number', models.CharField(max_length=30, unique=True)),
                ('capacity', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(20)])),
            ],
            options={
                'ordering': ['registration_number'],
            },
        ),
        migrations.CreateModel(
            name='Flight',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start', models.DateTimeField()),
                ('start_airport', models.CharField(max_length=30)),
                ('landing', models.DateTimeField()),
                ('landing_airport', models.CharField(max_length=30)),
                ('airplane', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='flights', to='flights.Airplane')),
                ('crew', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='flights', to='crews.Crew')),
            ],
            options={
                'ordering': ['start'],
            },
        ),
        migrations.CreateModel(
            name='Passenger',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30)),
                ('surname', models.CharField(max_length=30)),
            ],
            options={
                'ordering': ['surname', 'name'],
            },
        ),
        migrations.CreateModel(
            name='Ticket',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('count', models.PositiveIntegerField()),
                ('flight', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flights.Flight')),
                ('passenger', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='flights.Passenger')),
            ],
            options={
                'ordering': ['passenger'],
            },
        ),
        migrations.AlterUniqueTogether(
            name='passenger',
            unique_together={('name', 'surname')},
        ),
        migrations.AddField(
            model_name='flight',
            name='passengers',
            field=models.ManyToManyField(related_name='flights', through='flights.Ticket', to='flights.Passenger'),
        ),
        migrations.AlterUniqueTogether(
            name='ticket',
            unique_together={('passenger', 'flight')},
        ),
    ]
