# Generated by Django 2.2.12 on 2020-06-25 11:19

import django.contrib.postgres.fields
import django.db.models.deletion
import simple_history.models
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("metadata", "0013_barriertag"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("barriers", "0064_auto_20200623_1522"),
    ]

    operations = [
        migrations.CreateModel(
            name="PublicBarrier",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_on",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                ("modified_on", models.DateTimeField(auto_now=True, null=True)),
                ("archived", models.BooleanField(default=False)),
                ("archived_on", models.DateTimeField(blank=True, null=True)),
                ("archived_reason", models.TextField(blank=True, null=True)),
                ("unarchived_reason", models.TextField(blank=True, null=True)),
                ("unarchived_on", models.DateTimeField(blank=True, null=True)),
                ("title", models.CharField(max_length=255, null=True)),
                ("summary", models.TextField(null=True)),
                (
                    "status",
                    models.PositiveIntegerField(
                        choices=[
                            (0, "Unfinished"),
                            (1, "Open: Pending action"),
                            (2, "Open: In progress"),
                            (5, "Dormant"),
                            (6, "Archived"),
                            (7, "Unknown"),
                            (3, "Resolved: In part"),
                            (4, "Resolved: In full"),
                        ],
                        default=0,
                    ),
                ),
                ("country", models.UUIDField()),
                (
                    "sectors",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.UUIDField(),
                        blank=True,
                        default=list,
                        size=None,
                    ),
                ),
                (
                    "archived_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "barrier",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="barriers.BarrierInstance",
                    ),
                ),
                (
                    "categories",
                    models.ManyToManyField(
                        related_name="public_barriers", to="metadata.Category"
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "modified_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "unarchived_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="HistoricalPublicBarrier",
            fields=[
                (
                    "id",
                    models.IntegerField(
                        auto_created=True, blank=True, db_index=True, verbose_name="ID"
                    ),
                ),
                (
                    "created_on",
                    models.DateTimeField(
                        blank=True, db_index=True, editable=False, null=True
                    ),
                ),
                (
                    "modified_on",
                    models.DateTimeField(blank=True, editable=False, null=True),
                ),
                ("archived", models.BooleanField(default=False)),
                ("archived_on", models.DateTimeField(blank=True, null=True)),
                ("archived_reason", models.TextField(blank=True, null=True)),
                ("unarchived_reason", models.TextField(blank=True, null=True)),
                ("unarchived_on", models.DateTimeField(blank=True, null=True)),
                ("title", models.CharField(max_length=255, null=True)),
                ("summary", models.TextField(null=True)),
                (
                    "status",
                    models.PositiveIntegerField(
                        choices=[
                            (0, "Unfinished"),
                            (1, "Open: Pending action"),
                            (2, "Open: In progress"),
                            (5, "Dormant"),
                            (6, "Archived"),
                            (7, "Unknown"),
                            (3, "Resolved: In part"),
                            (4, "Resolved: In full"),
                        ],
                        default=0,
                    ),
                ),
                ("country", models.UUIDField()),
                (
                    "sectors",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.UUIDField(),
                        blank=True,
                        default=list,
                        size=None,
                    ),
                ),
                ("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,
                    ),
                ),
                (
                    "archived_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "barrier",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to="barriers.BarrierInstance",
                    ),
                ),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "history_user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "modified_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "unarchived_by",
                    models.ForeignKey(
                        blank=True,
                        db_constraint=False,
                        null=True,
                        on_delete=django.db.models.deletion.DO_NOTHING,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "historical public barrier",
                "ordering": ("-history_date", "-history_id"),
                "get_latest_by": "history_date",
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
    ]
