<reponame>City-of-Helsinki/apartment-application-service
# Generated by Django 2.2.24 on 2021-09-01 09:29

import django.db.models.deletion
import enumfields.fields
from django.db import migrations, models

import application_form.enums


class Migration(migrations.Migration):

    dependencies = [
        ("apartment", "0006_alter_apartment_number_to_charfield"),
        ("application_form", "0028_application_apartment_state"),
    ]

    operations = [
        migrations.CreateModel(
            name="ApartmentQueue",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "apartment",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="queue",
                        to="apartment.Apartment",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ApartmentQueueApplication",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "queue_position",
                    models.IntegerField(verbose_name="position in queue"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="LotteryEvent",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "apartment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="lottery_events",
                        to="apartment.Apartment",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="application",
            name="submitted_late",
            field=models.BooleanField(default=False, verbose_name="submitted late"),
        ),
        migrations.AlterField(
            model_name="application",
            name="apartments",
            field=models.ManyToManyField(
                blank=True,
                related_name="applications",
                through="application_form.ApplicationApartment",
                to="apartment.Apartment",
            ),
        ),
        migrations.AlterField(
            model_name="applicationapartment",
            name="apartment",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="application_apartments",
                to="apartment.Apartment",
            ),
        ),
        migrations.AlterField(
            model_name="applicationapartment",
            name="application",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="application_apartments",
                to="application_form.Application",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="applicationapartment",
            unique_together={("application", "priority_number")},
        ),
        migrations.CreateModel(
            name="ApartmentQueueChangeEvent",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "type",
                    enumfields.fields.EnumField(
                        enum=application_form.enums.ApartmentQueueChangeEventType,
                        max_length=15,
                        verbose_name="change type",
                    ),
                ),
                ("comment", models.CharField(max_length=255, verbose_name="comment")),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "queue_application",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="change_events",
                        to="application_form.ApartmentQueueApplication",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="apartmentqueueapplication",
            name="application_apartment",
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="queue_application",
                to="application_form.ApplicationApartment",
            ),
        ),
        migrations.AddField(
            model_name="apartmentqueueapplication",
            name="queue",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="queue_applications",
                to="application_form.ApartmentQueue",
            ),
        ),
        migrations.CreateModel(
            name="LotteryEventResult",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "result_position",
                    models.IntegerField(verbose_name="result position"),
                ),
                (
                    "application_apartment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="lottery_results",
                        to="application_form.ApplicationApartment",
                    ),
                ),
                (
                    "event",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="results",
                        to="application_form.LotteryEvent",
                    ),
                ),
            ],
            options={
                "unique_together": {("event", "application_apartment")},
            },
        ),
        migrations.AlterUniqueTogether(
            name="apartmentqueueapplication",
            unique_together={("queue", "application_apartment")},
        ),
    ]

# Generated by Django 2.2.24 on 2021-09-01 09:29

import django.db.models.deletion
import enumfields.fields
from django.db import migrations, models

import application_form.enums


class Migration(migrations.Migration):

    dependencies = [
        ("apartment", "0006_alter_apartment_number_to_charfield"),
        ("application_form", "0028_application_apartment_state"),
    ]

    operations = [
        migrations.CreateModel(
            name="ApartmentQueue",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "apartment",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="queue",
                        to="apartment.Apartment",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ApartmentQueueApplication",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "queue_position",
                    models.IntegerField(verbose_name="position in queue"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="LotteryEvent",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "apartment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="lottery_events",
                        to="apartment.Apartment",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="application",
            name="submitted_late",
            field=models.BooleanField(default=False, verbose_name="submitted late"),
        ),
        migrations.AlterField(
            model_name="application",
            name="apartments",
            field=models.ManyToManyField(
                blank=True,
                related_name="applications",
                through="application_form.ApplicationApartment",
                to="apartment.Apartment",
            ),
        ),
        migrations.AlterField(
            model_name="applicationapartment",
            name="apartment",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="application_apartments",
                to="apartment.Apartment",
            ),
        ),
        migrations.AlterField(
            model_name="applicationapartment",
            name="application",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="application_apartments",
                to="application_form.Application",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="applicationapartment",
            unique_together={("application", "priority_number")},
        ),
        migrations.CreateModel(
            name="ApartmentQueueChangeEvent",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "type",
                    enumfields.fields.EnumField(
                        enum=application_form.enums.ApartmentQueueChangeEventType,
                        max_length=15,
                        verbose_name="change type",
                    ),
                ),
                ("comment", models.CharField(max_length=255, verbose_name="comment")),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "queue_application",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="change_events",
                        to="application_form.ApartmentQueueApplication",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="apartmentqueueapplication",
            name="application_apartment",
            field=models.OneToOneField(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="queue_application",
                to="application_form.ApplicationApartment",
            ),
        ),
        migrations.AddField(
            model_name="apartmentqueueapplication",
            name="queue",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="queue_applications",
                to="application_form.ApartmentQueue",
            ),
        ),
        migrations.CreateModel(
            name="LotteryEventResult",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "result_position",
                    models.IntegerField(verbose_name="result position"),
                ),
                (
                    "application_apartment",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="lottery_results",
                        to="application_form.ApplicationApartment",
                    ),
                ),
                (
                    "event",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="results",
                        to="application_form.LotteryEvent",
                    ),
                ),
            ],
            options={
                "unique_together": {("event", "application_apartment")},
            },
        ),
        migrations.AlterUniqueTogether(
            name="apartmentqueueapplication",
            unique_together={("queue", "application_apartment")},
        ),
    ]
# Generated by Django 2.2.24 on 2021-09-01 09:29