<gh_stars>1-10
# Generated by Django 3.1.2 on 2020-10-26 12:09

import django.contrib.postgres.fields
import django.db.models.deletion
import django.utils.timezone
import enumfields.fields
import model_utils.fields
import simple_history.models
from django.conf import settings
from django.db import migrations, models

import hours.enums


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="DataSource",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "id",
                    models.CharField(max_length=100, primary_key=True, serialize=False),
                ),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "user_editable",
                    models.BooleanField(
                        default=False, verbose_name="Objects may be edited by users"
                    ),
                ),
            ],
            options={
                "verbose_name": "Data source",
                "verbose_name_plural": "Data sources",
            },
        ),
        migrations.CreateModel(
            name="DatePeriod",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="Start date"
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="End date"
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "override",
                    models.BooleanField(
                        db_index=True, default=False, verbose_name="Override"
                    ),
                ),
            ],
            options={
                "verbose_name": "Period",
                "verbose_name_plural": "Periods",
            },
        ),
        migrations.CreateModel(
            name="Resource",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "address",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_fi",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_sv",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_en",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "resource_type",
                    enumfields.fields.EnumField(
                        default="unit",
                        enum=hours.enums.ResourceType,
                        max_length=100,
                        verbose_name="Resource type",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(blank=True, null=True, verbose_name="Extra data"),
                ),
                (
                    "children",
                    models.ManyToManyField(
                        blank=True,
                        related_name="parents",
                        to="hours.Resource",
                        verbose_name="Sub resources",
                    ),
                ),
            ],
            options={
                "verbose_name": "Resource",
                "verbose_name_plural": "Resources",
            },
        ),
        migrations.CreateModel(
            name="TimeSpanGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "period",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="time_span_groups",
                        to="hours.dateperiod",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TimeSpan",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="Start time"
                    ),
                ),
                (
                    "end_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="End time"
                    ),
                ),
                (
                    "full_day",
                    models.BooleanField(default=False, verbose_name="24 hours"),
                ),
                (
                    "weekdays",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=enumfields.fields.EnumIntegerField(
                            default=None,
                            enum=hours.enums.Weekday,
                            verbose_name="Weekday",
                        ),
                        blank=True,
                        null=True,
                        size=None,
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="time_spans",
                        to="hours.timespangroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Time span",
                "verbose_name_plural": "Time spans",
            },
        ),
        migrations.CreateModel(
            name="Rule",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "context",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleContext,
                        max_length=100,
                        verbose_name="Context",
                    ),
                ),
                (
                    "subject",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleSubject,
                        max_length=100,
                        verbose_name="Subject",
                    ),
                ),
                (
                    "start",
                    models.IntegerField(blank=True, null=True, verbose_name="Start"),
                ),
                (
                    "frequency_ordinal",
                    models.PositiveIntegerField(
                        blank=True, null=True, verbose_name="Frequency (ordinal)"
                    ),
                ),
                (
                    "frequency_modifier",
                    enumfields.fields.EnumField(
                        blank=True,
                        enum=hours.enums.FrequencyModifier,
                        max_length=100,
                        null=True,
                        verbose_name="Frequency (modifier)",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="rules",
                        to="hours.timespangroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Rule",
                "verbose_name_plural": "Rules",
            },
        ),
        migrations.CreateModel(
            name="ResourceOrigin",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "origin_id",
                    models.CharField(
                        db_index=True, max_length=100, verbose_name="Origin ID"
                    ),
                ),
                (
                    "data_source",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="hours.datasource",
                    ),
                ),
                (
                    "resource",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="hours.resource"
                    ),
                ),
            ],
            options={
                "verbose_name": "Resource origin",
                "verbose_name_plural": "Resource origins",
            },
        ),
        migrations.AddField(
            model_name="resource",
            name="data_sources",
            field=models.ManyToManyField(
                through="hours.ResourceOrigin", to="hours.DataSource"
            ),
        ),
        migrations.AddField(
            model_name="resource",
            name="last_modified_by",
            field=models.ForeignKey(
                editable=False,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.CreateModel(
            name="HistoricalTimeSpan",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="Start time"
                    ),
                ),
                (
                    "end_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="End time"
                    ),
                ),
                (
                    "full_day",
                    models.BooleanField(default=False, verbose_name="24 hours"),
                ),
                (
                    "weekdays",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=enumfields.fields.EnumIntegerField(
                            default=None,
                            enum=hours.enums.Weekday,
                            verbose_name="Weekday",
                        ),
                        blank=True,
                        null=True,
                        size=None,
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.timespangroup",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Time span",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalRule",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "context",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleContext,
                        max_length=100,
                        verbose_name="Context",
                    ),
                ),
                (
                    "subject",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleSubject,
                        max_length=100,
                        verbose_name="Subject",
                    ),
                ),
                (
                    "start",
                    models.IntegerField(blank=True, null=True, verbose_name="Start"),
                ),
                (
                    "frequency_ordinal",
                    models.PositiveIntegerField(
                        blank=True, null=True, verbose_name="Frequency (ordinal)"
                    ),
                ),
                (
                    "frequency_modifier",
                    enumfields.fields.EnumField(
                        blank=True,
                        enum=hours.enums.FrequencyModifier,
                        max_length=100,
                        null=True,
                        verbose_name="Frequency (modifier)",
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.timespangroup",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Rule",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalResource",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "address",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_fi",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_sv",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_en",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "resource_type",
                    enumfields.fields.EnumField(
                        default="unit",
                        enum=hours.enums.ResourceType,
                        max_length=100,
                        verbose_name="Resource type",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(blank=True, null=True, verbose_name="Extra data"),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "last_modified_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Resource",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalDatePeriod",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="Start date"
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="End date"
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "override",
                    models.BooleanField(
                        db_index=True, default=False, verbose_name="Override"
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "resource",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.resource",
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Period",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalDataSource",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("id", models.CharField(db_index=True, max_length=100)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "user_editable",
                    models.BooleanField(
                        default=False, verbose_name="Objects may be edited by users"
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Data source",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.AddField(
            model_name="dateperiod",
            name="resource",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="date_periods",
                to="hours.resource",
            ),
        ),
        migrations.AddConstraint(
            model_name="resourceorigin",
            constraint=models.UniqueConstraint(
                fields=("data_source", "origin_id"),
                name="unique_identifier_per_data_source",
            ),
        ),
    ]

# Generated by Django 3.1.2 on 2020-10-26 12:09

import django.contrib.postgres.fields
import django.db.models.deletion
import django.utils.timezone
import enumfields.fields
import model_utils.fields
import simple_history.models
from django.conf import settings
from django.db import migrations, models

import hours.enums


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="DataSource",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "id",
                    models.CharField(max_length=100, primary_key=True, serialize=False),
                ),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "user_editable",
                    models.BooleanField(
                        default=False, verbose_name="Objects may be edited by users"
                    ),
                ),
            ],
            options={
                "verbose_name": "Data source",
                "verbose_name_plural": "Data sources",
            },
        ),
        migrations.CreateModel(
            name="DatePeriod",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="Start date"
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="End date"
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "override",
                    models.BooleanField(
                        db_index=True, default=False, verbose_name="Override"
                    ),
                ),
            ],
            options={
                "verbose_name": "Period",
                "verbose_name_plural": "Periods",
            },
        ),
        migrations.CreateModel(
            name="Resource",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "address",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_fi",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_sv",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_en",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "resource_type",
                    enumfields.fields.EnumField(
                        default="unit",
                        enum=hours.enums.ResourceType,
                        max_length=100,
                        verbose_name="Resource type",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(blank=True, null=True, verbose_name="Extra data"),
                ),
                (
                    "children",
                    models.ManyToManyField(
                        blank=True,
                        related_name="parents",
                        to="hours.Resource",
                        verbose_name="Sub resources",
                    ),
                ),
            ],
            options={
                "verbose_name": "Resource",
                "verbose_name_plural": "Resources",
            },
        ),
        migrations.CreateModel(
            name="TimeSpanGroup",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "period",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="time_span_groups",
                        to="hours.dateperiod",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="TimeSpan",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="Start time"
                    ),
                ),
                (
                    "end_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="End time"
                    ),
                ),
                (
                    "full_day",
                    models.BooleanField(default=False, verbose_name="24 hours"),
                ),
                (
                    "weekdays",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=enumfields.fields.EnumIntegerField(
                            default=None,
                            enum=hours.enums.Weekday,
                            verbose_name="Weekday",
                        ),
                        blank=True,
                        null=True,
                        size=None,
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="time_spans",
                        to="hours.timespangroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Time span",
                "verbose_name_plural": "Time spans",
            },
        ),
        migrations.CreateModel(
            name="Rule",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "context",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleContext,
                        max_length=100,
                        verbose_name="Context",
                    ),
                ),
                (
                    "subject",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleSubject,
                        max_length=100,
                        verbose_name="Subject",
                    ),
                ),
                (
                    "start",
                    models.IntegerField(blank=True, null=True, verbose_name="Start"),
                ),
                (
                    "frequency_ordinal",
                    models.PositiveIntegerField(
                        blank=True, null=True, verbose_name="Frequency (ordinal)"
                    ),
                ),
                (
                    "frequency_modifier",
                    enumfields.fields.EnumField(
                        blank=True,
                        enum=hours.enums.FrequencyModifier,
                        max_length=100,
                        null=True,
                        verbose_name="Frequency (modifier)",
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="rules",
                        to="hours.timespangroup",
                    ),
                ),
            ],
            options={
                "verbose_name": "Rule",
                "verbose_name_plural": "Rules",
            },
        ),
        migrations.CreateModel(
            name="ResourceOrigin",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "origin_id",
                    models.CharField(
                        db_index=True, max_length=100, verbose_name="Origin ID"
                    ),
                ),
                (
                    "data_source",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="hours.datasource",
                    ),
                ),
                (
                    "resource",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="hours.resource"
                    ),
                ),
            ],
            options={
                "verbose_name": "Resource origin",
                "verbose_name_plural": "Resource origins",
            },
        ),
        migrations.AddField(
            model_name="resource",
            name="data_sources",
            field=models.ManyToManyField(
                through="hours.ResourceOrigin", to="hours.DataSource"
            ),
        ),
        migrations.AddField(
            model_name="resource",
            name="last_modified_by",
            field=models.ForeignKey(
                editable=False,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.CreateModel(
            name="HistoricalTimeSpan",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="Start time"
                    ),
                ),
                (
                    "end_time",
                    models.TimeField(
                        blank=True, db_index=True, null=True, verbose_name="End time"
                    ),
                ),
                (
                    "full_day",
                    models.BooleanField(default=False, verbose_name="24 hours"),
                ),
                (
                    "weekdays",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=enumfields.fields.EnumIntegerField(
                            default=None,
                            enum=hours.enums.Weekday,
                            verbose_name="Weekday",
                        ),
                        blank=True,
                        null=True,
                        size=None,
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.timespangroup",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Time span",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalRule",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "context",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleContext,
                        max_length=100,
                        verbose_name="Context",
                    ),
                ),
                (
                    "subject",
                    enumfields.fields.EnumField(
                        enum=hours.enums.RuleSubject,
                        max_length=100,
                        verbose_name="Subject",
                    ),
                ),
                (
                    "start",
                    models.IntegerField(blank=True, null=True, verbose_name="Start"),
                ),
                (
                    "frequency_ordinal",
                    models.PositiveIntegerField(
                        blank=True, null=True, verbose_name="Frequency (ordinal)"
                    ),
                ),
                (
                    "frequency_modifier",
                    enumfields.fields.EnumField(
                        blank=True,
                        enum=hours.enums.FrequencyModifier,
                        max_length=100,
                        null=True,
                        verbose_name="Frequency (modifier)",
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.timespangroup",
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Rule",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalResource",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "address",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_fi",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_sv",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "address_en",
                    models.TextField(
                        blank=True, null=True, verbose_name="Street address"
                    ),
                ),
                (
                    "resource_type",
                    enumfields.fields.EnumField(
                        default="unit",
                        enum=hours.enums.ResourceType,
                        max_length=100,
                        verbose_name="Resource type",
                    ),
                ),
                (
                    "extra_data",
                    models.JSONField(blank=True, null=True, verbose_name="Extra data"),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "last_modified_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        editable=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Resource",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalDatePeriod",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                (
                    "name",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_fi",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_sv",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "name_en",
                    models.CharField(
                        blank=True, max_length=255, null=True, verbose_name="Name"
                    ),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "start_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="Start date"
                    ),
                ),
                (
                    "end_date",
                    models.DateField(
                        blank=True, db_index=True, null=True, verbose_name="End date"
                    ),
                ),
                (
                    "resource_state",
                    enumfields.fields.EnumField(
                        default="undefined",
                        enum=hours.enums.State,
                        max_length=100,
                        verbose_name="Resource state",
                    ),
                ),
                (
                    "override",
                    models.BooleanField(
                        db_index=True, default=False, verbose_name="Override"
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "resource",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="hours.resource",
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Period",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name="HistoricalDataSource",
            fields=[
                (
                    "created",
                    model_utils.fields.AutoCreatedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="created",
                    ),
                ),
                (
                    "modified",
                    model_utils.fields.AutoLastModifiedField(
                        default=django.utils.timezone.now,
                        editable=False,
                        verbose_name="modified",
                    ),
                ),
                ("is_removed", models.BooleanField(default=False)),
                ("id", models.CharField(db_index=True, max_length=100)),
                ("name", models.CharField(max_length=255, verbose_name="Name")),
                (
                    "name_fi",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_sv",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "name_en",
                    models.CharField(max_length=255, null=True, verbose_name="Name"),
                ),
                (
                    "description",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_fi",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_sv",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "description_en",
                    models.TextField(blank=True, null=True, verbose_name="Description"),
                ),
                (
                    "user_editable",
                    models.BooleanField(
                        default=False, verbose_name="Objects may be edited by users"
                    ),
                ),
                ("history_id", models.AutoField(primary_key=True, serialize=False)),
                ("history_date", models.DateTimeField()),
                ("history_change_reason", models.CharField(max_length=100, null=True)),
                (
                    "history_type",
                    models.CharField(
                        choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")],
                        max_length=1,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical Data source",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.AddField(
            model_name="dateperiod",
            name="resource",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.PROTECT,
                related_name="date_periods",
                to="hours.resource",
            ),
        ),
        migrations.AddConstraint(
            model_name="resourceorigin",
            constraint=models.UniqueConstraint(
                fields=("data_source", "origin_id"),
                name="unique_identifier_per_data_source",
            ),
        ),
    ]
# Generated by Django 3.1.2 on 2020-10-26 12:09