# Generated by Django 4.2.8 on 2025-11-08 16:35

from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import django_lifecycle.mixins
import model_utils.fields
import uuid


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Country",
            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",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("name", models.CharField(max_length=255, unique=True)),
                (
                    "code",
                    models.CharField(
                        help_text="ISO 3166-1 alpha-2 country code",
                        max_length=2,
                        unique=True,
                    ),
                ),
                (
                    "code3",
                    models.CharField(
                        blank=True,
                        help_text="ISO 3166-1 alpha-3 country code",
                        max_length=3,
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "countries",
                "db_table": "countries",
                "ordering": ["name"],
            },
            bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name="Subdivision",
            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",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                (
                    "code",
                    models.CharField(
                        help_text="ISO 3166-2 subdivision code (without country prefix)",
                        max_length=10,
                    ),
                ),
                (
                    "subdivision_type",
                    models.CharField(
                        blank=True,
                        help_text="Type of subdivision (state, province, region, etc.)",
                        max_length=50,
                    ),
                ),
                (
                    "country",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subdivisions",
                        to="core.country",
                    ),
                ),
            ],
            options={
                "db_table": "subdivisions",
                "ordering": ["country", "name"],
                "unique_together": {("country", "code")},
            },
            bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
        ),
        migrations.CreateModel(
            name="Locality",
            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",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                (
                    "latitude",
                    models.DecimalField(
                        blank=True, decimal_places=6, max_digits=9, null=True
                    ),
                ),
                (
                    "longitude",
                    models.DecimalField(
                        blank=True, decimal_places=6, max_digits=9, null=True
                    ),
                ),
                (
                    "subdivision",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="localities",
                        to="core.subdivision",
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "localities",
                "db_table": "localities",
                "ordering": ["subdivision", "name"],
                "indexes": [
                    models.Index(
                        fields=["subdivision", "name"],
                        name="localities_subdivi_675d5a_idx",
                    )
                ],
            },
            bases=(django_lifecycle.mixins.LifecycleModelMixin, models.Model),
        ),
    ]
