# Generated by Django 4.2.11 on 2025-10-20 21:41

from decimal import Decimal
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import utilities.json


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('dcim', '0185_gfk_indexes'),
        ('extras', '0107_cachedvalue_extras_cachedvalue_object'),
    ]

    operations = [
        migrations.CreateModel(
            name='OpticalGrid',
            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)),
                ('comments', models.TextField(blank=True)),
                ('name', models.CharField(blank=True, default='', max_length=100)),
                ('spacing', models.IntegerField(blank=True)),
                ('description', models.TextField(blank=True)),
            ],
            options={
                'verbose_name': 'Optical Grid',
                'verbose_name_plural': 'Optical Grids',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='OpticalGridType',
            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)),
                ('comments', models.TextField(blank=True)),
                ('name', models.CharField(blank=True, default='', max_length=100)),
                ('spacing', models.IntegerField()),
                ('description', models.TextField(blank=True)),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Optical Grid Type',
                'verbose_name_plural': 'Optical Grid Types',
                'ordering': ['spacing'],
            },
        ),
        migrations.CreateModel(
            name='OpticalSpan',
            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)),
                ('comments', models.TextField(blank=True)),
                ('name', models.CharField(blank=True, default='', max_length=100)),
                ('description', models.TextField(blank=True)),
                ('vendor_circuit_id', models.CharField(max_length=100, unique=True, validators=[django.core.validators.RegexValidator(message='No spaces allowed.', regex='^\\S+$')])),
                ('vendor', models.CharField(max_length=100)),
                ('grid', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='spans', to='netbox_optics.opticalgrid')),
                ('mux_a', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='optical_spans_as_mux_a', to='dcim.device')),
                ('mux_z', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='optical_spans_as_mux_z', to='dcim.device')),
                ('site_a', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='optical_spans_as_a', to='dcim.site')),
                ('site_b', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='optical_spans_as_b', to='dcim.site')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Optical Span',
                'verbose_name_plural': 'Optical Spans',
                'ordering': ['vendor_circuit_id'],
            },
        ),
        migrations.CreateModel(
            name='OpticalGridWavelength',
            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)),
                ('value', models.DecimalField(decimal_places=2, max_digits=6, validators=[django.core.validators.DecimalValidator(decimal_places=2, max_digits=6), django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('grid', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allowed_wavelengths', to='netbox_optics.opticalgrid')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Grid Wavelength',
                'verbose_name_plural': 'Grid Wavelengths',
                'ordering': ['value'],
                'unique_together': {('grid', 'value')},
            },
        ),
        migrations.AddField(
            model_name='opticalgrid',
            name='grid_type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='grids', to='netbox_optics.opticalgridtype'),
        ),
        migrations.AddField(
            model_name='opticalgrid',
            name='tags',
            field=taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag'),
        ),
        migrations.CreateModel(
            name='OpticalConnection',
            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)),
                ('comments', models.TextField(blank=True)),
                ('name', models.CharField(blank=True, default='', max_length=100)),
                ('tx_power', models.PositiveSmallIntegerField(blank=True, null=True, validators=[django.core.validators.MaxValueValidator(127)])),
                ('description', models.TextField(blank=True)),
                ('interface_a', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connections_as_a', to='dcim.interface')),
                ('interface_z', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connections_as_z', to='dcim.interface')),
                ('span', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connections', to='netbox_optics.opticalspan')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('wavelength', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connections', to='netbox_optics.opticalgridwavelength')),
            ],
            options={
                'verbose_name': 'Optical Connection',
                'verbose_name_plural': 'Optical Connections',
            },
        ),
        migrations.CreateModel(
            name='MuxWavelengthMap',
            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)),
                ('mux', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mux_maps', to='dcim.device')),
                ('port', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dcim.interface')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('wavelength', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='netbox_optics.opticalgridwavelength')),
            ],
            options={
                'verbose_name': 'Mux Wavelength Map',
                'verbose_name_plural': 'Mux Wavelength Maps',
            },
        ),
        migrations.CreateModel(
            name='OpticalGridTypeWavelength',
            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)),
                ('value', models.DecimalField(decimal_places=2, max_digits=6, validators=[django.core.validators.DecimalValidator(decimal_places=2, max_digits=6), django.core.validators.MinValueValidator(Decimal('0.01'))])),
                ('grid_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='allowed_wavelengths', to='netbox_optics.opticalgridtype')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Grid Type Wavelength',
                'verbose_name_plural': 'Grid Type Wavelengths',
                'ordering': ['value'],
                'unique_together': {('grid_type', 'value')},
            },
        ),
        migrations.AddConstraint(
            model_name='opticalconnection',
            constraint=models.UniqueConstraint(fields=('interface_a',), name='unique_interface_a'),
        ),
        migrations.AddConstraint(
            model_name='opticalconnection',
            constraint=models.UniqueConstraint(fields=('interface_z',), name='unique_interface_z'),
        ),
        migrations.AddConstraint(
            model_name='opticalconnection',
            constraint=models.UniqueConstraint(fields=('wavelength', 'span'), name='unique_wavelength_per_span'),
        ),
        migrations.AddConstraint(
            model_name='opticalconnection',
            constraint=models.CheckConstraint(check=models.Q(('interface_a', models.F('interface_z')), _negated=True), name='interface_a_not_equal_interface_z'),
        ),
        migrations.AddConstraint(
            model_name='muxwavelengthmap',
            constraint=models.UniqueConstraint(fields=('mux', 'port'), name='unique_mux_port'),
        ),
        migrations.AddConstraint(
            model_name='muxwavelengthmap',
            constraint=models.UniqueConstraint(fields=('mux', 'wavelength'), name='unique_mux_wavelength'),
        ),
    ]