# Generated by Django 5.2.11 on 2026-03-17 15:42

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("extras", "0134_owner"),
        ("netbox_dhcp", "0002_import_option_definitions"),
        ("users", "0015_owner"),
    ]

    operations = [
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.CheckConstraint(
                condition=models.Q(
                    models.Q(
                        models.Q(
                            ("client_class__isnull", True),
                            ("dhcp_server__isnull", True),
                            ("standard", True),
                        ),
                        models.Q(
                            ("client_class__isnull", True),
                            ("dhcp_server__isnull", False),
                            ("standard", False),
                        ),
                        models.Q(
                            ("client_class__isnull", False),
                            ("dhcp_server__isnull", True),
                            ("standard", False),
                        ),
                        _connector="OR",
                    )
                ),
                name="option_definition_standard_or_unique_parent_object",
                violation_error_message="Option definitions must either be standard or have a unique parent object",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("standard", True)),
                fields=("space", "name"),
                name="standard_option_definition_unique_name",
                violation_error_message="Standard option definitions must be uniqe in space and name",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("standard", True)),
                fields=("space", "code"),
                name="standard_option_definition_unique_code",
                violation_error_message="Standard option definitions must be uniqe in space and code",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("dhcp_server__isnull", False)),
                fields=("space", "name", "dhcp_server"),
                name="global_option_definition_unique_name",
                violation_error_message="Global custom option definitions must be uniqe in space and name",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("dhcp_server__isnull", False)),
                fields=("space", "code", "dhcp_server"),
                name="global_option_definition_unique_code",
                violation_error_message="Global custom option definitions must be uniqe in space and code",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("client_class__isnull", False)),
                fields=("space", "name", "client_class"),
                name="client_class_option_definition_unique_name",
                violation_error_message="Classification custom option definitions must be uniqe in space and name",
            ),
        ),
        migrations.AddConstraint(
            model_name="optiondefinition",
            constraint=models.UniqueConstraint(
                condition=models.Q(("client_class__isnull", False)),
                fields=("space", "code", "client_class"),
                name="client_class_option_definition_unique_code",
                violation_error_message="Classification custom option definitions must be uniqe in space and code",
            ),
        ),
    ]
