# Generated by Django 5.2.17 on 2026-09-03 21:25

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


class Migration(migrations.Migration):

    dependencies = [
        ('customers', '0004_notificationpreference_email_enabled_and_more'),
        ('network', '0001_initial'),
        ('tenancy', '0004_staffprofile'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PointOfPresence',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('code', models.CharField(help_text='Unique POP identifier per organization, e.g. POP-LHR-01', max_length=50)),
                ('name', models.CharField(help_text='Human-readable name, e.g. Gulberg Main Core POP', max_length=150)),
                ('pop_type', models.CharField(choices=[('CORE', 'Core POP'), ('AGGREGATION', 'Aggregation Node'), ('DISTRIBUTION', 'Distribution Point / Cabinet'), ('TOWER', 'Wireless Tower Site'), ('CABINET', 'Street Cabinet / ODF'), ('CENTRAL_OFFICE', 'Central Office'), ('OTHER', 'Other Facility')], default='DISTRIBUTION', max_length=30)),
                ('address', models.TextField(blank=True, help_text='Physical street address or building details')),
                ('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)),
                ('rack_capacity_units', models.PositiveIntegerField(default=42, help_text='Total rack units available at facility')),
                ('power_backup_type', models.CharField(blank=True, default='UPS_GENERATOR', help_text='e.g. SOLAR_HYBRID, UPS_GENERATOR, BATTERY_BANK, GRID_ONLY', max_length=100)),
                ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('MAINTENANCE', 'Under Maintenance'), ('DEGRADED', 'Degraded Performance'), ('OFFLINE', 'Offline')], default='ACTIVE', max_length=30)),
                ('notes', models.TextField(blank=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('area', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='pop_sites', to='customers.area')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_records', to='tenancy.organization')),
                ('supervisor', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='supervised_pops', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'network_point_of_presence',
                'ordering': ['name'],
            },
        ),
        migrations.AddField(
            model_name='networknode',
            name='pop_site',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='nodes', to='network.pointofpresence'),
        ),
        migrations.AddIndex(
            model_name='networknode',
            index=models.Index(fields=['organization', 'pop_site'], name='network_node_org_pop_idx'),
        ),
        migrations.AddIndex(
            model_name='pointofpresence',
            index=models.Index(fields=['organization', 'status'], name='pop_org_status_idx'),
        ),
        migrations.AddIndex(
            model_name='pointofpresence',
            index=models.Index(fields=['organization', 'pop_type'], name='pop_org_type_idx'),
        ),
        migrations.AddIndex(
            model_name='pointofpresence',
            index=models.Index(fields=['organization', 'area'], name='pop_org_area_idx'),
        ),
        migrations.AddConstraint(
            model_name='pointofpresence',
            constraint=models.UniqueConstraint(fields=('organization', 'code'), name='unique_pop_code_per_org'),
        ),
    ]
