# Generated by Django 6.0.3 on 2026-03-25 14:36

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Locality',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='اسم المحلية')),
                ('code', models.CharField(blank=True, max_length=10, null=True, verbose_name='الكود')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='locality_created', to=settings.AUTH_USER_MODEL)),
                ('deleted_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='locality_deleted', to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='locality_updated', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'محلية',
                'verbose_name_plural': 'المحليات',
            },
        ),
        migrations.CreateModel(
            name='Area',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='اسم المنطقة')),
                ('code', models.CharField(blank=True, max_length=10, null=True, verbose_name='الكود')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='area_created', to=settings.AUTH_USER_MODEL)),
                ('deleted_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='area_deleted', to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='area_updated', to=settings.AUTH_USER_MODEL)),
                ('locality', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='areas', to='geography.locality', verbose_name='المحلية')),
            ],
            options={
                'verbose_name': 'منطقة',
                'verbose_name_plural': 'المناطق',
            },
        ),
        migrations.CreateModel(
            name='Location',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, verbose_name='اسم الموقع')),
                ('code', models.CharField(blank=True, max_length=10, null=True, verbose_name='الكود')),
                ('zoning', models.CharField(blank=True, choices=[('commercial', 'تجارية'), ('residential', 'سكنية'), ('industrial', 'صناعية'), ('services', 'خدمية'), ('mixed', 'مختلطة')], max_length=20, null=True, verbose_name='المنطقة التصنيفية')),
                ('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True, verbose_name='خط العرض')),
                ('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True, verbose_name='خط الطول')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
                ('area', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='locations', to='geography.area', verbose_name='المنطقة')),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='location_created', to=settings.AUTH_USER_MODEL)),
                ('deleted_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='location_deleted', to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='location_updated', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'موقع',
                'verbose_name_plural': 'المواقع',
            },
        ),
        migrations.CreateModel(
            name='State',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True, verbose_name='اسم الولاية')),
                ('code', models.CharField(max_length=10, unique=True, verbose_name='الكود')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('deleted_at', models.DateTimeField(blank=True, null=True)),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='state_created', to=settings.AUTH_USER_MODEL)),
                ('deleted_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='state_deleted', to=settings.AUTH_USER_MODEL)),
                ('updated_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='state_updated', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'ولاية',
                'verbose_name_plural': 'الولايات',
            },
        ),
        migrations.AddField(
            model_name='locality',
            name='state',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='localities', to='geography.state', verbose_name='الولاية'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['deleted_at'], name='geography_a_deleted_19eddb_idx'),
        ),
        migrations.AddIndex(
            model_name='area',
            index=models.Index(fields=['name'], name='geography_a_name_b52439_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='area',
            unique_together={('name', 'locality')},
        ),
        migrations.AddIndex(
            model_name='location',
            index=models.Index(fields=['deleted_at'], name='geography_l_deleted_746fb5_idx'),
        ),
        migrations.AddIndex(
            model_name='location',
            index=models.Index(fields=['name'], name='geography_l_name_6e2f10_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='location',
            unique_together={('name', 'area')},
        ),
        migrations.AddIndex(
            model_name='state',
            index=models.Index(fields=['deleted_at'], name='geography_s_deleted_6d46b0_idx'),
        ),
        migrations.AddIndex(
            model_name='state',
            index=models.Index(fields=['name'], name='geography_s_name_b5fbff_idx'),
        ),
        migrations.AddIndex(
            model_name='locality',
            index=models.Index(fields=['deleted_at'], name='geography_l_deleted_a8063d_idx'),
        ),
        migrations.AddIndex(
            model_name='locality',
            index=models.Index(fields=['name'], name='geography_l_name_c78a30_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='locality',
            unique_together={('name', 'state')},
        ),
    ]
