# Generated by Django 3.2 on 2021-04-25 19:51

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='Astronaut',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('astronaut_id', models.CharField(max_length=256, unique=True)),
                ('name', models.CharField(max_length=40)),
                ('original_name', models.CharField(max_length=40)),
                ('sex', models.CharField(choices=[('M', 'Male'), ('F', 'Female'), ('U', 'Unspecified')], default='U', max_length=1)),
                ('background', models.CharField(choices=[('M', 'Military'), ('C', 'Civilian'), ('U', 'Unspecified')], default='U', max_length=1)),
                ('birth_year', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900), django.core.validators.MaxValueValidator(2010)])),
            ],
        ),
        migrations.CreateModel(
            name='AstronautOccupation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('role', models.CharField(max_length=40)),
                ('year_of_join', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900), django.core.validators.MaxValueValidator(2021)])),
                ('astronaut', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.astronaut')),
            ],
        ),
        migrations.CreateModel(
            name='AstronautSelection',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('year_of_selection', models.PositiveSmallIntegerField(validators=[django.core.validators.MinValueValidator(1900), django.core.validators.MaxValueValidator(2021)])),
                ('astronaut', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.astronaut')),
            ],
        ),
        migrations.CreateModel(
            name='Country',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=2, unique=True)),
                ('name', models.CharField(blank=True, max_length=40, null=True)),
                ('continent', models.CharField(choices=[('Africa', 'Africa'), ('Americas', 'Americas'), ('Asia', 'Asia'), ('Europe', 'Europe'), ('Oceania', 'Oceania'), ('Antarctica', 'Antarctica')], default='Americas', max_length=10)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Engine',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=256, unique=True)),
                ('mass', models.FloatField(blank=True, null=True)),
                ('impulse', models.FloatField(blank=True, null=True)),
                ('thrust', models.FloatField(blank=True, null=True)),
                ('isp', models.FloatField(blank=True, null=True)),
                ('burn_duration', models.FloatField(blank=True, null=True)),
                ('chambers', models.PositiveSmallIntegerField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Launch',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('launch_id', models.CharField(max_length=10, unique=True)),
                ('date', models.DateField()),
                ('success_or_fail', models.CharField(choices=[('Success', 'Success'), ('Fail', 'Fail'), ('unknown', 'unknown')], max_length=20)),
                ('type_of_launch', models.CharField(choices=[('Orbital', 'Orbital'), ('DeepSpaceMission', 'DeepSpaceMission'), ('unknown', 'unknown')], max_length=20)),
            ],
        ),
        migrations.CreateModel(
            name='LaunchVehicle',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=256, unique=True)),
                ('min_stage', models.IntegerField(blank=True, null=True)),
                ('max_stage', models.IntegerField(blank=True, null=True)),
                ('launch_mass', models.FloatField(blank=True, null=True)),
                ('TO_thrust', models.FloatField(blank=True, null=True)),
                ('length', models.FloatField(blank=True, null=True)),
                ('diameter', models.FloatField(blank=True, null=True)),
                ('vehicle_class', models.CharField(choices=[('D', 'Extraterrestrial Deep Space Launch'), ('M', 'Missile'), ('O', 'Orbital Vehicle'), ('R', 'Research Rocket'), ('V', 'Reentry Test Vehicle'), ('X', 'Exoatmospheric test'), ('Y', 'Exoatmospheric weather rocket'), ('A', 'Endoatmospheric missile'), ('C', 'Cruise missile'), ('Q', 'Endoatmospheric reentry test vehicle'), ('T', 'Endoatmospheric test/research'), ('W', 'Endoatmospheric Weather rocket')], default='O', max_length=1)),
            ],
        ),
        migrations.CreateModel(
            name='Mission',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=30, unique=True)),
                ('astronauts', models.ManyToManyField(blank=True, related_name='missions', through='space_missions.AstronautOccupation', to='space_missions.Astronaut')),
                ('launch', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.launch')),
            ],
        ),
        migrations.CreateModel(
            name='Organisation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('code', models.CharField(max_length=256, unique=True)),
                ('name', models.CharField(max_length=256, null=True)),
                ('english_name', models.CharField(max_length=256, null=True)),
                ('location', models.CharField(max_length=256, null=True)),
                ('longitude', models.FloatField(null=True)),
                ('latitude', models.FloatField(null=True)),
                ('country', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.country')),
                ('parent_organisation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.organisation')),
            ],
        ),
        migrations.CreateModel(
            name='Stage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=256, unique=True)),
                ('dry_mass', models.FloatField(null=True)),
                ('launch_mass', models.FloatField(null=True)),
                ('thrust', models.FloatField(null=True)),
                ('burn_duration', models.FloatField(null=True)),
                ('length', models.FloatField(null=True)),
                ('diameter', models.FloatField(null=True)),
                ('engine', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.engine')),
                ('manufacturer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.organisation')),
            ],
        ),
        migrations.CreateModel(
            name='VehicleStage',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('stage_number', models.CharField(choices=[('-1', '-1'), ('0', '0'), ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('F', 'Fairing')], max_length=2)),
                ('dummy', models.CharField(choices=[('yes', 'yes'), ('no', 'no')], max_length=3)),
                ('launch_vehicle', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.launchvehicle')),
                ('stage', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.stage')),
            ],
            options={
                'unique_together': {('launch_vehicle', 'stage', 'stage_number', 'dummy')},
            },
        ),
        migrations.CreateModel(
            name='Selection',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=40, unique=True)),
                ('astronauts', models.ManyToManyField(related_name='selections', through='space_missions.AstronautSelection', to='space_missions.Astronaut')),
                ('missions', models.ManyToManyField(to='space_missions.Mission')),
            ],
        ),
        migrations.AddField(
            model_name='launchvehicle',
            name='manufacturer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.organisation'),
        ),
        migrations.AddField(
            model_name='launchvehicle',
            name='stages',
            field=models.ManyToManyField(blank=True, through='space_missions.VehicleStage', to='space_missions.Stage'),
        ),
        migrations.AddField(
            model_name='launch',
            name='launch_vehicle',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.launchvehicle'),
        ),
        migrations.AddField(
            model_name='launch',
            name='organisation',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.organisation'),
        ),
        migrations.AddField(
            model_name='engine',
            name='manufacturer',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.organisation'),
        ),
        migrations.AddField(
            model_name='astronautselection',
            name='selection',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.selection'),
        ),
        migrations.AddField(
            model_name='astronautoccupation',
            name='mission',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='space_missions.mission'),
        ),
        migrations.AddField(
            model_name='astronaut',
            name='nationality',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='space_missions.country'),
        ),
        migrations.AlterUniqueTogether(
            name='astronautselection',
            unique_together={('astronaut', 'selection', 'year_of_selection')},
        ),
        migrations.AlterUniqueTogether(
            name='astronautoccupation',
            unique_together={('astronaut', 'mission', 'role', 'year_of_join')},
        ),
    ]
