# Generated by Django 5.0.9 on 2024-10-07 11:49

import django.db.models.deletion
import taggit.managers
import timezone_field.fields
import utilities.json
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('circuits', '0044_circuit_groups'),
        ('dcim', '0191_module_bay_rebuild'),
        ('extras', '0121_customfield_related_object_filter'),
    ]

    operations = [
        migrations.CreateModel(
            name='PhoneDelivery',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('created', models.DateTimeField(auto_now_add=True, null=True)),
                ('last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
                ('delivery', models.CharField(blank=True, null=True)),
                ('channel_count', models.PositiveBigIntegerField(blank=True, null=True)),
                ('status', models.CharField(max_length=30)),
                ('ndi', models.PositiveBigIntegerField(blank=True, null=True)),
                ('dto', models.PositiveBigIntegerField(blank=True, null=True)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('comments', models.TextField(blank=True)),
                ('provider', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.RESTRICT, to='circuits.provider')),
                ('site', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, to='dcim.site')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Phone Delivery',
                'verbose_name_plural': 'Phone Deliveries',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PhoneDID',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('created', models.DateTimeField(auto_now_add=True, null=True)),
                ('last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
                ('start', models.PositiveBigIntegerField(blank=True)),
                ('end', models.PositiveBigIntegerField(blank=True)),
                ('delivery', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sop_phone.phonedelivery')),
                ('site', models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='dcim.site')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'DID Range',
                'verbose_name_plural': 'DIDs',
                'ordering': ('start',),
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PhoneMaintainer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('created', models.DateTimeField(auto_now_add=True, null=True)),
                ('last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('comments', models.TextField(blank=True)),
                ('name', models.CharField(unique=True)),
                ('slug', models.SlugField(blank=True, max_length=100, unique=True)),
                ('status', models.CharField(default='Unknown', max_length=30)),
                ('physical_address', models.CharField(blank=True, max_length=200, null=True)),
                ('shipping_address', models.CharField(blank=True, max_length=200, null=True)),
                ('time_zone', timezone_field.fields.TimeZoneField(blank=True, null=True)),
                ('latitude', models.DecimalField(blank=True, decimal_places=6, max_digits=8, null=True)),
                ('longitude', models.DecimalField(blank=True, decimal_places=6, max_digits=9, null=True)),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Phone Maintainer',
                'verbose_name_plural': 'Phone Maintainers',
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='PhoneInfo',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('created', models.DateTimeField(auto_now_add=True, null=True)),
                ('last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('custom_field_data', models.JSONField(blank=True, default=dict, encoder=utilities.json.CustomFieldJSONEncoder)),
                ('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='dcim.site')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('maintainer', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='sop_phone.phonemaintainer')),
            ],
            options={
                'verbose_name': 'Information',
                'verbose_name_plural': 'Informations',
                'abstract': False,
            },
        ),
        migrations.AddConstraint(
            model_name='phonedelivery',
            constraint=models.UniqueConstraint(fields=('ndi',), name='sop_phone_phonedelivery_unique_ndi', violation_error_message='NDI must be unique.'),
        ),
        migrations.AddConstraint(
            model_name='phonedelivery',
            constraint=models.UniqueConstraint(fields=('delivery', 'site'), name='sop_phone_phonedelivery_unique_delivery_method_site', violation_error_message='Delivery method must be unique in a site.'),
        ),
        migrations.AddConstraint(
            model_name='phonedid',
            constraint=models.UniqueConstraint(fields=('start',), name='sop_phone_phonedid_unique_start_number', violation_error_message='Start number must be unique.'),
        ),
        migrations.AddConstraint(
            model_name='phonedid',
            constraint=models.UniqueConstraint(fields=('end',), name='sop_phone_phonedid_unique_end_number', violation_error_message='End number must be unique.'),
        ),
        migrations.AddConstraint(
            model_name='phonedid',
            constraint=models.CheckConstraint(check=models.Q(('end__gte', models.F('start')), ('start__biabs__bilog__bifloor', models.F('end'))), name='sop_phone_phonedid_end_greater_than_start', violation_error_message='End number must be greater than or equal to start number.'),
        ),
        migrations.AddConstraint(
            model_name='phonemaintainer',
            constraint=models.UniqueConstraint(fields=('name',), name='sop_phone_phonemaintainer_unique_name', violation_error_message='Maintainer name must be unique.'),
        ),
        migrations.AddConstraint(
            model_name='phonemaintainer',
            constraint=models.UniqueConstraint(fields=('slug',), name='sop_phone_phonemaintainer_unique_slug', violation_error_message='Maintainer slug must be unique.'),
        ),
        migrations.AddConstraint(
            model_name='phoneinfo',
            constraint=models.UniqueConstraint(fields=('site',), name='sop_phone_phoneinfo_unique_site', violation_error_message='Site must be unique.'),
        ),
    ]
