# Generated by Django 3.2.9 on 2021-11-19 07:57

from django.db import migrations, models
import django.db.models.deletion
import django.db.models.expressions
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='School',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('slug', models.SlugField(max_length=255, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Student',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('email', models.EmailField(max_length=255)),
                ('identifier', models.UUIDField(default=uuid.uuid4)),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='students', to='testing_examples.school')),
            ],
            options={
                'unique_together': {('identifier', 'school'), ('email', 'school')},
            },
        ),
        migrations.CreateModel(
            name='SchoolCourse',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('slug', models.SlugField(max_length=255)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='school_courses', to='testing_examples.school')),
            ],
        ),
        migrations.CreateModel(
            name='Roster',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('active', models.BooleanField(default=True)),
                ('deactivated_at', models.DateField(blank=True, null=True)),
                ('school_course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rosters', to='testing_examples.schoolcourse')),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rosters', to='testing_examples.student')),
            ],
        ),
        migrations.AddConstraint(
            model_name='schoolcourse',
            constraint=models.CheckConstraint(check=models.Q(('start_date__lt', django.db.models.expressions.F('end_date'))), name='school_course_start_before_end'),
        ),
        migrations.AlterUniqueTogether(
            name='schoolcourse',
            unique_together={('name', 'slug', 'start_date', 'end_date')},
        ),
        migrations.AddConstraint(
            model_name='roster',
            constraint=models.CheckConstraint(check=models.Q(('start_date__lt', django.db.models.expressions.F('end_date'))), name='roster_start_before_end'),
        ),
    ]

# Generated by Django 3.2.9 on 2021-11-19 07:57

from django.db import migrations, models
import django.db.models.deletion
import django.db.models.expressions
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='School',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('slug', models.SlugField(max_length=255, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Student',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('email', models.EmailField(max_length=255)),
                ('identifier', models.UUIDField(default=uuid.uuid4)),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='students', to='testing_examples.school')),
            ],
            options={
                'unique_together': {('identifier', 'school'), ('email', 'school')},
            },
        ),
        migrations.CreateModel(
            name='SchoolCourse',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('slug', models.SlugField(max_length=255)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='school_courses', to='testing_examples.school')),
            ],
        ),
        migrations.CreateModel(
            name='Roster',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('active', models.BooleanField(default=True)),
                ('deactivated_at', models.DateField(blank=True, null=True)),
                ('school_course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rosters', to='testing_examples.schoolcourse')),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rosters', to='testing_examples.student')),
            ],
        ),
        migrations.AddConstraint(
            model_name='schoolcourse',
            constraint=models.CheckConstraint(check=models.Q(('start_date__lt', django.db.models.expressions.F('end_date'))), name='school_course_start_before_end'),
        ),
        migrations.AlterUniqueTogether(
            name='schoolcourse',
            unique_together={('name', 'slug', 'start_date', 'end_date')},
        ),
        migrations.AddConstraint(
            model_name='roster',
            constraint=models.CheckConstraint(check=models.Q(('start_date__lt', django.db.models.expressions.F('end_date'))), name='roster_start_before_end'),
        ),
    ]

# Generated by Django 3.2.9 on 2021-11-19 07:57