# Generated by Django 3.2.20 on 2023-08-02 11:07

from django.db import migrations

from api.metadata.constants import OrganisationType

ORGANISATIONS = [
    {
        "name": "Department for Levelling Up, Housing and Communities",
        "organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
    },
    {
        "name": "Department for Energy Security and Net Zero",
        "organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
    },
    {
        "name": "Department for Science, Innovation and Technology",
        "organisation_type": OrganisationType.MINISTERIAL_DEPARTMENTS,
    },
]


def create_organisations(apps, schema_editor):
    Organisation = apps.get_model("metadata", "Organisation")

    for item in ORGANISATIONS:
        Organisation.objects.create(**item)


def delete_organisations(apps, schema_editor):
    Organisation = apps.get_model("metadata", "Organisation")

    for item in ORGANISATIONS:
        Organisation.objects.delete(**item)


class Migration(migrations.Migration):
    dependencies = [
        ('metadata', '0034_exporttype'),
    ]

    operations = [
        migrations.RunPython(create_organisations, reverse_code=delete_organisations),
    ]
