# Generated by Django 5.2.9 on 2026-01-19 10:37

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("dcim", "0225_gfk_indexes"),
        ("extras", "0134_owner"),
        ("ipam", "0086_gfk_indexes"),
        ("users", "0015_owner"),
        ("virtualization", "0052_gfk_indexes"),
    ]

    operations = [
        migrations.CreateModel(
            name="DHCPCluster",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                (
                    "status",
                    models.CharField(blank=True, default="active", max_length=50),
                ),
                (
                    "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={
                "verbose_name": "DHCP Cluster",
                "verbose_name_plural": "DHCP Clusters",
                "ordering": ("name",),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="DHCPServer",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("next_server", models.CharField(blank=True, max_length=15, null=True)),
                (
                    "server_hostname",
                    models.CharField(blank=True, max_length=64, null=True),
                ),
                (
                    "boot_file_name",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
                ("valid_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "min_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "min_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("offer_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_send_updates", models.BooleanField(blank=True, null=True)),
                ("ddns_override_no_update", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_override_client_update",
                    models.BooleanField(blank=True, null=True),
                ),
                ("ddns_replace_client_name", models.CharField(blank=True, null=True)),
                ("ddns_generated_prefix", models.CharField(blank=True, null=True)),
                ("ddns_qualifying_suffix", models.CharField(blank=True, null=True)),
                ("ddns_update_on_renew", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_conflict_resolution_mode",
                    models.CharField(blank=True, null=True),
                ),
                (
                    "ddns_ttl_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                ("ddns_ttl", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_min", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_max", models.PositiveIntegerField(blank=True, null=True)),
                ("hostname_char_set", models.CharField(blank=True, max_length=255)),
                (
                    "hostname_char_replacement",
                    models.CharField(blank=True, max_length=255),
                ),
                ("renew_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("rebind_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("match_client_id", models.BooleanField(blank=True, null=True)),
                ("authoritative", models.BooleanField(blank=True, null=True)),
                ("reservations_global", models.BooleanField(blank=True, null=True)),
                (
                    "reservations_out_of_pool",
                    models.BooleanField(blank=True, null=True),
                ),
                ("reservations_in_subnet", models.BooleanField(blank=True, null=True)),
                ("calculate_tee_times", models.BooleanField(blank=True, null=True)),
                (
                    "t1_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "t2_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "cache_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("cache_max_age", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "adaptive_lease_time_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("store_extended_info", models.BooleanField(blank=True, null=True)),
                ("allocator", models.CharField(blank=True, null=True)),
                ("pd_allocator", models.CharField(blank=True, null=True)),
                (
                    "status",
                    models.CharField(blank=True, default="active", max_length=50),
                ),
                (
                    "decline_probation_period",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "host_reservation_identifiers",
                    netbox_dhcp.fields.choice_array.ChoiceArrayField(
                        base_field=models.CharField(),
                        blank=True,
                        default=list,
                        null=True,
                        size=None,
                    ),
                ),
                ("echo_client_id", models.BooleanField(blank=True, null=True)),
                (
                    "relay_supplied_options",
                    django.contrib.postgres.fields.ArrayField(
                        base_field=models.PositiveIntegerField(
                            validators=[
                                django.core.validators.MinValueValidator(0),
                                django.core.validators.MaxValueValidator(255),
                            ]
                        ),
                        blank=True,
                        default=list,
                        size=None,
                    ),
                ),
                ("server_id", models.CharField(blank=True, null=True)),
                (
                    "device",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="netbox_dhcp_dhcp_servers",
                        to="dcim.device",
                    ),
                ),
                (
                    "device_interfaces",
                    models.ManyToManyField(
                        blank=True,
                        related_name="netbox_dhcp_dhcp_servers",
                        to="dcim.interface",
                    ),
                ),
                (
                    "dhcp_cluster",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="dhcp_servers",
                        to="netbox_dhcp.dhcpcluster",
                    ),
                ),
                (
                    "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"
                    ),
                ),
                (
                    "virtual_machine",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="netbox_dhcp_dhcp_servers",
                        to="virtualization.virtualmachine",
                    ),
                ),
                (
                    "virtual_machine_interfaces",
                    models.ManyToManyField(
                        blank=True,
                        related_name="netbox_dhcp_dhcp_servers",
                        to="virtualization.vminterface",
                    ),
                ),
            ],
            options={
                "verbose_name": "DHCP Server",
                "verbose_name_plural": "DHCP Servers",
                "ordering": ("name",),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="ClientClass",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("next_server", models.CharField(blank=True, max_length=15, null=True)),
                (
                    "server_hostname",
                    models.CharField(blank=True, max_length=64, null=True),
                ),
                (
                    "boot_file_name",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
                ("valid_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "min_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "min_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("offer_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                ("test", models.TextField(blank=True)),
                ("template_test", models.TextField(blank=True)),
                ("only_in_additional_list", models.BooleanField(blank=True, null=True)),
                (
                    "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"
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="client_class_definition_set",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
            ],
            options={
                "verbose_name": "Client Class",
                "verbose_name_plural": "Client Classes",
                "ordering": ("-weight", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="DHCPServerInterface",
            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,
                    ),
                ),
                (
                    "device_interface",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="netbox_dhcp_dhcp_server_interfaces",
                        to="dcim.interface",
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        blank=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "virtual_machine_interface",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="netbox_dhcp_dhcp_server_interfaces",
                        to="virtualization.vminterface",
                    ),
                ),
            ],
            options={
                "verbose_name": "DHCP Server Interface",
                "verbose_name_plural": "DHCP Server Interfaces",
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.AddField(
            model_name="dhcpserver",
            name="interfaces",
            field=models.ManyToManyField(
                blank=True,
                related_name="dhcp_servers",
                to="netbox_dhcp.dhcpserverinterface",
            ),
        ),
        migrations.CreateModel(
            name="OptionDefinition",
            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=255)),
                ("family", models.PositiveIntegerField(default=4)),
                ("space", models.CharField(default="dhcp4")),
                (
                    "code",
                    models.PositiveIntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(1),
                            django.core.validators.MaxValueValidator(255),
                        ]
                    ),
                ),
                ("type", models.CharField()),
                (
                    "record_types",
                    netbox_dhcp.fields.choice_array.ChoiceArrayField(
                        base_field=models.CharField(), blank=True, null=True, size=None
                    ),
                ),
                ("encapsulate", models.CharField(blank=True, null=True)),
                ("array", models.BooleanField(blank=True, null=True)),
                ("standard", models.BooleanField(default=False)),
                (
                    "client_class",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="option_definitions",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="option_definitions",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
                (
                    "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={
                "verbose_name": "Option Definition",
                "verbose_name_plural": "Option Definitions",
                "ordering": ("space", "code", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="Option",
            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)),
                ("assigned_object_id", models.PositiveBigIntegerField()),
                ("data", models.CharField(blank=True)),
                ("csv_format", models.BooleanField(blank=True, null=True)),
                ("send_option", models.CharField(blank=True, null=True)),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                (
                    "assigned_object_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "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"
                    ),
                ),
                (
                    "definition",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="options",
                        to="netbox_dhcp.optiondefinition",
                    ),
                ),
            ],
            options={
                "verbose_name": "Option",
                "verbose_name_plural": "Options",
                "ordering": (
                    "definition__space",
                    "definition__code",
                    "definition__name",
                    "weight",
                ),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="SharedNetwork",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("next_server", models.CharField(blank=True, max_length=15, null=True)),
                (
                    "server_hostname",
                    models.CharField(blank=True, max_length=64, null=True),
                ),
                (
                    "boot_file_name",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
                ("valid_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "min_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "min_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("offer_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_send_updates", models.BooleanField(blank=True, null=True)),
                ("ddns_override_no_update", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_override_client_update",
                    models.BooleanField(blank=True, null=True),
                ),
                ("ddns_replace_client_name", models.CharField(blank=True, null=True)),
                ("ddns_generated_prefix", models.CharField(blank=True, null=True)),
                ("ddns_qualifying_suffix", models.CharField(blank=True, null=True)),
                ("ddns_update_on_renew", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_conflict_resolution_mode",
                    models.CharField(blank=True, null=True),
                ),
                (
                    "ddns_ttl_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                ("ddns_ttl", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_min", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_max", models.PositiveIntegerField(blank=True, null=True)),
                ("hostname_char_set", models.CharField(blank=True, max_length=255)),
                (
                    "hostname_char_replacement",
                    models.CharField(blank=True, max_length=255),
                ),
                ("renew_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("rebind_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("match_client_id", models.BooleanField(blank=True, null=True)),
                ("authoritative", models.BooleanField(blank=True, null=True)),
                ("reservations_global", models.BooleanField(blank=True, null=True)),
                (
                    "reservations_out_of_pool",
                    models.BooleanField(blank=True, null=True),
                ),
                ("reservations_in_subnet", models.BooleanField(blank=True, null=True)),
                ("calculate_tee_times", models.BooleanField(blank=True, null=True)),
                (
                    "t1_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "t2_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "cache_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("cache_max_age", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "adaptive_lease_time_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("store_extended_info", models.BooleanField(blank=True, null=True)),
                ("allocator", models.CharField(blank=True, null=True)),
                ("pd_allocator", models.CharField(blank=True, null=True)),
                ("relay", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "interface_id",
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                ("rapid_commit", models.BooleanField(blank=True, null=True)),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_shared_networks",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
                (
                    "evaluate_additional_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="evaluate_%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="users.owner",
                    ),
                ),
                (
                    "prefix",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="netbox_dhcp_shared_networks",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "server_interfaces",
                    models.ManyToManyField(
                        blank=True, to="netbox_dhcp.dhcpserverinterface"
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "verbose_name": "Shared Network",
                "verbose_name_plural": "Shared Networks",
                "ordering": ("-weight", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="Subnet",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("next_server", models.CharField(blank=True, max_length=15, null=True)),
                (
                    "server_hostname",
                    models.CharField(blank=True, max_length=64, null=True),
                ),
                (
                    "boot_file_name",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
                ("valid_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "min_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_valid_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "min_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                (
                    "max_preferred_lifetime",
                    models.PositiveIntegerField(blank=True, null=True),
                ),
                ("offer_lifetime", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_send_updates", models.BooleanField(blank=True, null=True)),
                ("ddns_override_no_update", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_override_client_update",
                    models.BooleanField(blank=True, null=True),
                ),
                ("ddns_replace_client_name", models.CharField(blank=True, null=True)),
                ("ddns_generated_prefix", models.CharField(blank=True, null=True)),
                ("ddns_qualifying_suffix", models.CharField(blank=True, null=True)),
                ("ddns_update_on_renew", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_conflict_resolution_mode",
                    models.CharField(blank=True, null=True),
                ),
                (
                    "ddns_ttl_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                ("ddns_ttl", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_min", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_max", models.PositiveIntegerField(blank=True, null=True)),
                ("hostname_char_set", models.CharField(blank=True, max_length=255)),
                (
                    "hostname_char_replacement",
                    models.CharField(blank=True, max_length=255),
                ),
                ("renew_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("rebind_timer", models.PositiveIntegerField(blank=True, null=True)),
                ("match_client_id", models.BooleanField(blank=True, null=True)),
                ("authoritative", models.BooleanField(blank=True, null=True)),
                ("reservations_global", models.BooleanField(blank=True, null=True)),
                (
                    "reservations_out_of_pool",
                    models.BooleanField(blank=True, null=True),
                ),
                ("reservations_in_subnet", models.BooleanField(blank=True, null=True)),
                ("calculate_tee_times", models.BooleanField(blank=True, null=True)),
                (
                    "t1_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "t2_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                (
                    "cache_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("cache_max_age", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "adaptive_lease_time_threshold",
                    models.DecimalField(
                        blank=True, decimal_places=2, max_digits=3, null=True
                    ),
                ),
                ("store_extended_info", models.BooleanField(blank=True, null=True)),
                ("allocator", models.CharField(blank=True, null=True)),
                ("pd_allocator", models.CharField(blank=True, null=True)),
                ("relay", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "interface_id",
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                ("rapid_commit", models.BooleanField(blank=True, null=True)),
                ("subnet_id", models.PositiveIntegerField(blank=True)),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_subnets",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
                (
                    "evaluate_additional_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="evaluate_%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="users.owner",
                    ),
                ),
                (
                    "prefix",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="netbox_dhcp_subnets",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "server_interfaces",
                    models.ManyToManyField(
                        blank=True, to="netbox_dhcp.dhcpserverinterface"
                    ),
                ),
                (
                    "shared_network",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_subnets",
                        to="netbox_dhcp.sharednetwork",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
            ],
            options={
                "verbose_name": "Subnet",
                "verbose_name_plural": "Subnets",
                "ordering": ("-weight", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="Pool",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("ddns_send_updates", models.BooleanField(blank=True, null=True)),
                ("ddns_override_no_update", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_override_client_update",
                    models.BooleanField(blank=True, null=True),
                ),
                ("ddns_replace_client_name", models.CharField(blank=True, null=True)),
                ("ddns_generated_prefix", models.CharField(blank=True, null=True)),
                ("ddns_qualifying_suffix", models.CharField(blank=True, null=True)),
                ("ddns_update_on_renew", models.BooleanField(blank=True, null=True)),
                (
                    "ddns_conflict_resolution_mode",
                    models.CharField(blank=True, null=True),
                ),
                (
                    "ddns_ttl_percent",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=4, null=True
                    ),
                ),
                ("ddns_ttl", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_min", models.PositiveIntegerField(blank=True, null=True)),
                ("ddns_ttl_max", models.PositiveIntegerField(blank=True, null=True)),
                ("hostname_char_set", models.CharField(blank=True, max_length=255)),
                (
                    "hostname_char_replacement",
                    models.CharField(blank=True, max_length=255),
                ),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                ("pool_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "evaluate_additional_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="evaluate_%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "ip_range",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="netbox_dhcp_pools",
                        to="ipam.iprange",
                    ),
                ),
                (
                    "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"
                    ),
                ),
                (
                    "subnet",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_pools",
                        to="netbox_dhcp.subnet",
                    ),
                ),
            ],
            options={
                "verbose_name": "Pool",
                "verbose_name_plural": "Pools",
                "ordering": ("-weight", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="PDPool",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("weight", models.PositiveSmallIntegerField(default=100)),
                ("pool_id", models.PositiveIntegerField(blank=True, null=True)),
                (
                    "delegated_length",
                    models.IntegerField(
                        validators=[
                            django.core.validators.MinValueValidator(0),
                            django.core.validators.MaxValueValidator(128),
                        ]
                    ),
                ),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "evaluate_additional_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="evaluate_%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "excluded_prefix",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="netbox_dhcp_pd_excluded_pools",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        to="users.owner",
                    ),
                ),
                (
                    "prefix",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="netbox_dhcp_pd_pools",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "tags",
                    taggit.managers.TaggableManager(
                        through="extras.TaggedItem", to="extras.Tag"
                    ),
                ),
                (
                    "subnet",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_pd_pools",
                        to="netbox_dhcp.subnet",
                    ),
                ),
            ],
            options={
                "verbose_name": "Prefix Delegation Pool",
                "verbose_name_plural": "Prefix Delegation Pools",
                "ordering": ("-weight", "name"),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.CreateModel(
            name="HostReservation",
            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(
                        db_collation="natural_sort", max_length=255, unique=True
                    ),
                ),
                ("next_server", models.CharField(blank=True, max_length=15, null=True)),
                (
                    "server_hostname",
                    models.CharField(blank=True, max_length=64, null=True),
                ),
                (
                    "boot_file_name",
                    models.CharField(blank=True, max_length=128, null=True),
                ),
                ("duid", models.CharField(blank=True, max_length=255, null=True)),
                ("flex_id", models.CharField(blank=True, max_length=255, null=True)),
                ("circuit_id", models.CharField(blank=True, max_length=255, null=True)),
                ("client_id", models.CharField(blank=True, max_length=255, null=True)),
                ("hostname", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "client_classes",
                    models.ManyToManyField(
                        blank=True,
                        related_name="%(class)s_set",
                        to="netbox_dhcp.clientclass",
                    ),
                ),
                (
                    "dhcp_server",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_host_reservations",
                        to="netbox_dhcp.dhcpserver",
                    ),
                ),
                (
                    "excluded_ipv6_prefixes",
                    models.ManyToManyField(
                        related_name="netbox_dhcp_excluded_ipv6_host_reservations",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "hw_address",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="netbox_dhcp_host_reservations",
                        to="dcim.macaddress",
                    ),
                ),
                (
                    "ipv4_address",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="netbox_dhcp_ipv4_host_reservations",
                        to="ipam.ipaddress",
                    ),
                ),
                (
                    "ipv6_addresses",
                    models.ManyToManyField(
                        related_name="netbox_dhcp_ipv6_host_reservations",
                        to="ipam.ipaddress",
                    ),
                ),
                (
                    "ipv6_prefixes",
                    models.ManyToManyField(
                        related_name="netbox_dhcp_ipv6_host_reservations",
                        to="ipam.prefix",
                    ),
                ),
                (
                    "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"
                    ),
                ),
                (
                    "subnet",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="child_host_reservations",
                        to="netbox_dhcp.subnet",
                    ),
                ),
            ],
            options={
                "verbose_name": "Host Reservation",
                "verbose_name_plural": "Host Reservations",
                "ordering": ("name",),
            },
            bases=(netbox.models.deletion.DeleteMixin, models.Model),
        ),
        migrations.AddConstraint(
            model_name="dhcpserverinterface",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        models.Q(
                            ("device_interface__isnull", False),
                            ("virtual_machine_interface__isnull", True),
                        ),
                        models.Q(
                            ("device_interface__isnull", True),
                            ("virtual_machine_interface__isnull", False),
                        ),
                        _connector="OR",
                    )
                ),
                name="dhcp_server_interface_device_vm",
                violation_error_message="Interface must refer to either a device or vm interface",
            ),
        ),
        migrations.AddConstraint(
            model_name="subnet",
            constraint=models.UniqueConstraint(
                fields=("subnet_id",), name="subnet_unique_subnet_id"
            ),
        ),
        migrations.AddConstraint(
            model_name="subnet",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        models.Q(
                            ("dhcp_server__isnull", False),
                            ("shared_network__isnull", True),
                        ),
                        models.Q(
                            ("dhcp_server__isnull", True),
                            ("shared_network__isnull", False),
                        ),
                        _connector="OR",
                    )
                ),
                name="subnet_unique_parent_object",
                violation_error_message="Either DHCP Server or Shared Network is required, not both",
            ),
        ),
        migrations.AddConstraint(
            model_name="hostreservation",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        models.Q(
                            ("dhcp_server__isnull", False), ("subnet__isnull", True)
                        ),
                        models.Q(
                            ("dhcp_server__isnull", True), ("subnet__isnull", False)
                        ),
                        _connector="OR",
                    )
                ),
                name="host_reservation_unique_parent_object",
                violation_error_message="Either DHCP Server or Subnet is required, not both",
            ),
        ),
    ]
