# Generated by Django 5.2.5 on 2026-01-16 23:40

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


class Migration(migrations.Migration):

    dependencies = [
        ('netbox_routing', '0018_reset_bgp_model'),
    ]

    operations = [
        migrations.RenameField(
            model_name='prefixlistentry',
            old_name='type',
            new_name='action',
        ),
        migrations.RenameField(
            model_name='routemapentry',
            old_name='type',
            new_name='action',
        ),
        migrations.AddField(
            model_name='prefixlist',
            name='family',
            field=models.PositiveSmallIntegerField(default=4),
        ),
        migrations.AlterField(
            model_name='prefixlistentry',
            name='ge',
            field=models.PositiveSmallIntegerField(
                blank=True,
                null=True,
                validators=[
                    django.core.validators.MinValueValidator(0),
                    django.core.validators.MaxValueValidator(128),
                ],
            ),
        ),
        migrations.AlterField(
            model_name='prefixlistentry',
            name='le',
            field=models.PositiveSmallIntegerField(
                blank=True,
                null=True,
                validators=[
                    django.core.validators.MinValueValidator(0),
                    django.core.validators.MaxValueValidator(128),
                ],
            ),
        ),
        migrations.AlterField(
            model_name='prefixlistentry',
            name='prefix_list',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='prefix_list_entries',
                to='netbox_routing.prefixlist',
            ),
        ),
        migrations.AlterField(
            model_name='routemapentry',
            name='route_map',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name='route_map_entries',
                to='netbox_routing.routemap',
            ),
        ),
        migrations.CreateModel(
            name='ASPath',
            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(max_length=100)),
                (
                    'owner',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to='users.owner',
                    ),
                ),
                (
                    'tags',
                    taggit.managers.TaggableManager(
                        through='extras.TaggedItem', to='extras.Tag'
                    ),
                ),
            ],
            options={
                'ordering': ['name'],
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name='ASPathEntry',
            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)),
                ('sequence', models.PositiveSmallIntegerField()),
                ('action', models.CharField(max_length=6)),
                (
                    'aspath',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='aspath_entries',
                        to='netbox_routing.aspath',
                    ),
                ),
                (
                    'owner',
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to='users.owner',
                    ),
                ),
                ('pattern', models.CharField(max_length=200)),
                (
                    'tags',
                    taggit.managers.TaggableManager(
                        through='extras.TaggedItem', to='extras.Tag'
                    ),
                ),
            ],
            options={
                'ordering': ['aspath', 'sequence'],
            },
            bases=(
                netbox.models.deletion.DeleteMixin,
                models.Model,
            ),
        ),
        migrations.AlterField(
            model_name='prefixlist',
            name='name',
            field=models.CharField(max_length=100),
        ),
        migrations.AlterField(
            model_name='routemap',
            name='name',
            field=models.CharField(max_length=100),
        ),
        migrations.AddConstraint(
            model_name='aspath',
            constraint=models.UniqueConstraint(
                django.db.models.functions.text.Lower('name'),
                name='netbox_routing_aspath_unique_name',
                violation_error_message='Name must be unique.',
            ),
        ),
        migrations.AddConstraint(
            model_name='aspathentry',
            constraint=models.UniqueConstraint(
                fields=('aspath', 'sequence'),
                name='netbox_routing_aspathentry_unique_aspath_sequence',
                violation_error_message='Prefix List sequence must be unique.',
            ),
        ),
        migrations.RemoveConstraint(
            model_name='prefixlistentry',
            name='netbox_routing_prefixlistentry_unique_prefixlist_sequence',
        ),
        migrations.RemoveConstraint(
            model_name='routemapentry',
            name='netbox_routing_routemapentry_unique_routemap_sequence',
        ),
        migrations.AddConstraint(
            model_name='prefixlistentry',
            constraint=models.UniqueConstraint(
                fields=('prefix_list', 'sequence'),
                name='netbox_routing_prefixlistentry_unique_prefixlist_sequence',
                violation_error_message='Prefix List sequence must be unique.',
            ),
        ),
        migrations.AddConstraint(
            model_name='routemapentry',
            constraint=models.UniqueConstraint(
                fields=('route_map', 'sequence'),
                name='netbox_routing_routemapentry_unique_routemap_sequence',
                violation_error_message='Route Map sequence must be unique.',
            ),
        ),
    ]
