# Generated by Django 3.1.2 on 2020-10-12 13:47

from django.db import migrations

TAGS = {
    "COVID-19": {
        "description": "Barrier imposed because of the COVID-19 (coronavirus) pandemic.",
        "order": 1,
        "show_at_reporting": True,
    },
    "NI Protocol": {
        "description": "Special provisions applied to goods from GB to avoid a hard border with Ireland when the UK leaves the EU.",
        "order": 3,
        "show_at_reporting": True,
    },
}


def create_nip_tag(apps, schema_editor):
    BarrierTag = apps.get_model("metadata", "BarrierTag")

    for title, defaults in TAGS.items():
        BarrierTag.objects.update_or_create(
            title=title,
            defaults=defaults,
        )


def delete_nip_tag(apps, schema_editor):
    BarrierTag = apps.get_model("metadata", "BarrierTag")
    BarrierTag.objects.filter(title="NI Protocol").delete()


class Migration(migrations.Migration):

    dependencies = [
        ("metadata", "0014_sectors"),
    ]

    operations = [
        migrations.RunPython(create_nip_tag, reverse_code=delete_nip_tag),
    ]
