# Generated by Django 3.0.7 on 2020-06-30 22:34

from django.db import migrations

PROVINCES = (
    ("AB", "Alberta"),
    ("BC", "British Columbia"),
    ("MB", "Manitoba"),
    ("NB", "New Brunswick"),
    ("NL", "Newfoundland and Labrador"),
    ("NS", "Nova Scotia"),
    ("NT", "Northwest Territories"),
    ("NU", "Nunavut"),
    ("ON", "Ontario"),
    ("PE", "Prince Edward Island"),
    ("QC", "Quebec"),
    ("SK", "Saskatchewan"),
    ("YT", "Yukon"),
)


def add_provinces(apps, schema_editor):
    # We can't import the HealthcareProvince model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Province = apps.get_model("profiles", "HealthcareProvince")
    for _abbr, _name in PROVINCES:
        temp = Province(abbr=_abbr, name=_name)
        temp.save()


class Migration(migrations.Migration):

    dependencies = [
        ("profiles", "0004_add_healthcareprovince_model"),
    ]

    operations = [
        migrations.RunPython(add_provinces),
    ]
