# Generated by Django 5.2.9 on 2026-02-16 19:44

import django.core.validators
import django.db.models.deletion
import netbox.models.deletion
import taggit.managers
import utilities.fields
import utilities.json
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('dcim', '0225_gfk_indexes'),
        ('extras', '0134_owner'),
        ('ipam', '0086_gfk_indexes'),
        ('netbox_routing', '0024_bfdprofile'),
        ('tenancy', '0022_add_comments_to_organizationalmodel'),
    ]

    operations = [
        migrations.CreateModel(
            name='IRRSource',
            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)),
                ('name', models.CharField(max_length=100, unique=True)),
                ('slug', models.SlugField(max_length=100, unique=True)),
                ('url', models.URLField()),
                ('sources', models.CharField(blank=True, max_length=200)),
                ('cache_ttl', models.PositiveIntegerField(blank=True, null=True)),
                ('sync_interval', models.PositiveIntegerField(default=1440, help_text='Minutes between automatic syncs (default: 1440 = 24 hours)', validators=[django.core.validators.MinValueValidator(1)])),
                ('enabled', models.BooleanField(db_index=True, default=True)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('comments', models.TextField(blank=True)),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'IRR Source',
                'verbose_name_plural': 'IRR Sources',
                'ordering': ['name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='IRRPrefixListConfig',
            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)),
                ('source_as_set', models.CharField(blank=True, max_length=100)),
                ('sync_interval', models.PositiveIntegerField(default=1440, help_text='Minutes between automatic syncs (default: 1440 = 24 hours)', validators=[django.core.validators.MinValueValidator(1)])),
                ('prefix_list', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='irr_config', to='netbox_routing.prefixlist')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('irr_source', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='irr_prefix_list_configs', to='netbox_peering_manager.irrsource')),
            ],
            options={
                'verbose_name': 'IRR Prefix List Config',
                'verbose_name_plural': 'IRR Prefix List Configs',
                'ordering': ['prefix_list__name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeerASN',
            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)),
                ('affiliated', models.BooleanField(db_index=True, default=False)),
                ('irr_as_set', models.CharField(blank=True, max_length=100)),
                ('ipv4_max_prefixes', models.PositiveIntegerField(blank=True, null=True)),
                ('ipv6_max_prefixes', models.PositiveIntegerField(blank=True, null=True)),
                ('peeringdb_id', models.PositiveIntegerField(blank=True, null=True, unique=True)),
                ('peeringdb_last_sync', models.DateTimeField(blank=True, db_index=True, null=True)),
                ('comments', models.TextField(blank=True)),
                ('asn', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='peer_asn', to='ipam.asn')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Peer ASN',
                'verbose_name_plural': 'Peer ASNs',
                'ordering': ['asn__asn'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringFabric',
            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)),
                ('name', models.CharField(max_length=100)),
                ('slug', models.SlugField(max_length=100)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('status', models.CharField(default='active', max_length=50)),
                ('comments', models.TextField(blank=True)),
                ('peer_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='netbox_routing.bgppeertemplate')),
                ('site', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='peering_fabrics', to='dcim.site')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('tenant', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='peering_fabrics', to='tenancy.tenant')),
            ],
            options={
                'verbose_name': 'Peering Fabric',
                'verbose_name_plural': 'Peering Fabrics',
                'ordering': ['name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringFabricPeeringDB',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('ix_id', models.PositiveIntegerField(unique=True)),
                ('name', models.CharField(blank=True, max_length=200)),
                ('city', models.CharField(blank=True, max_length=100)),
                ('country', models.CharField(blank=True, max_length=2)),
                ('website', models.URLField(blank=True)),
                ('tech_email', models.EmailField(blank=True, max_length=254)),
                ('last_sync', models.DateTimeField(auto_now=True)),
                ('fabric', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='peeringdb', to='netbox_peering_manager.peeringfabric')),
            ],
            options={
                'verbose_name': 'PeeringDB Info',
                'verbose_name_plural': 'PeeringDB Info',
            },
        ),
        migrations.CreateModel(
            name='PeeringFabricType',
            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)),
                ('name', models.CharField(max_length=100, unique=True)),
                ('slug', models.SlugField(max_length=100, unique=True)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('color', utilities.fields.ColorField(default='9e9e9e', max_length=6)),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'verbose_name': 'Peering Fabric Type',
                'verbose_name_plural': 'Peering Fabric Types',
                'ordering': ['name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.AddField(
            model_name='peeringfabric',
            name='type',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='fabrics', to='netbox_peering_manager.peeringfabrictype'),
        ),
        migrations.CreateModel(
            name='PeeringNetwork',
            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)),
                ('name', models.CharField(max_length=100)),
                ('status', models.CharField(db_index=True, default='active', max_length=50)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('comments', models.TextField(blank=True)),
                ('fabric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='networks', to='netbox_peering_manager.peeringfabric')),
                ('prefix', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='peering_networks', to='ipam.prefix')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('vlan', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='peering_networks', to='ipam.vlan')),
            ],
            options={
                'verbose_name': 'Peering Network',
                'verbose_name_plural': 'Peering Networks',
                'ordering': ['fabric', 'name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringConnection',
            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)),
                ('status', models.CharField(db_index=True, default='active', max_length=50)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('interface', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='peering_connections', to='dcim.interface')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('peering_network', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='connections', to='netbox_peering_manager.peeringnetwork')),
            ],
            options={
                'verbose_name': 'Peering Connection',
                'verbose_name_plural': 'Peering Connections',
                'ordering': ['peering_network', 'interface'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringNetworkPeeringDB',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('ixlan_id', models.PositiveIntegerField(unique=True)),
                ('name', models.CharField(blank=True, max_length=200)),
                ('mtu', models.PositiveIntegerField(blank=True, null=True)),
                ('rs_asn', models.PositiveBigIntegerField(blank=True, null=True)),
                ('dot1q_support', models.BooleanField(default=False)),
                ('last_sync', models.DateTimeField(auto_now=True)),
                ('network', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='peeringdb', to='netbox_peering_manager.peeringnetwork')),
            ],
            options={
                'verbose_name': 'PeeringDB IXLAN Info',
                'verbose_name_plural': 'PeeringDB IXLAN Info',
            },
        ),
        migrations.CreateModel(
            name='Relationship',
            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)),
                ('name', models.CharField(max_length=100, unique=True)),
                ('slug', models.SlugField(max_length=100, unique=True)),
                ('description', models.CharField(blank=True, max_length=200)),
                ('color', utilities.fields.ColorField(default='9e9e9e', max_length=6)),
                ('comments', models.TextField(blank=True)),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
            ],
            options={
                'ordering': ['name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringSession',
            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)),
                ('service_reference', models.CharField(blank=True, max_length=100)),
                ('bgp_peer', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, related_name='peering_session', to='netbox_routing.bgppeer')),
                ('peering_network', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='peering_sessions', to='netbox_peering_manager.peeringnetwork')),
                ('tags', taggit.managers.TaggableManager(through='extras.TaggedItem', to='extras.Tag')),
                ('relationship', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='peering_sessions', to='netbox_peering_manager.relationship')),
            ],
            options={
                'verbose_name': 'Peering Session',
                'verbose_name_plural': 'Peering Sessions',
                'ordering': ['bgp_peer__name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='PeeringDBPeer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False)),
                ('asn', models.PositiveBigIntegerField()),
                ('name', models.CharField(max_length=200)),
                ('ipv4_addr', models.GenericIPAddressField(blank=True, null=True, protocol='IPv4')),
                ('ipv6_addr', models.GenericIPAddressField(blank=True, null=True, protocol='IPv6')),
                ('is_rs_peer', models.BooleanField(default=False)),
                ('speed', models.PositiveIntegerField(default=0)),
                ('last_updated', models.DateTimeField(auto_now=True)),
                ('fabric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='peeringdb_peers', to='netbox_peering_manager.peeringfabric')),
            ],
            options={
                'verbose_name': 'PeeringDB Peer',
                'verbose_name_plural': 'PeeringDB Peers',
                'ordering': ['asn', 'name'],
                'unique_together': {('fabric', 'asn', 'ipv4_addr', 'ipv6_addr')},
            },
        ),
        migrations.AddConstraint(
            model_name='peeringfabric',
            constraint=models.UniqueConstraint(condition=models.Q(('site__isnull', False)), fields=('name', 'site'), name='unique_peeringfabric_name_site'),
        ),
        migrations.AddConstraint(
            model_name='peeringfabric',
            constraint=models.UniqueConstraint(condition=models.Q(('site__isnull', True)), fields=('name',), name='unique_peeringfabric_name_no_site'),
        ),
        migrations.AlterUniqueTogether(
            name='peeringnetwork',
            unique_together={('fabric', 'name')},
        ),
        migrations.AlterUniqueTogether(
            name='peeringconnection',
            unique_together={('peering_network', 'interface')},
        ),
    ]
