# Generated by Django 5.2.4 on 2025-09-25 05:36

import core.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0048_rename_socialprofile_verbose"),
        ("nodes", "0009_node_current_relation"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="NodeManager",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "provider",
                    models.CharField(
                        choices=[("godaddy", "GoDaddy")],
                        default="godaddy",
                        max_length=20,
                    ),
                ),
                (
                    "api_key",
                    core.fields.SigilShortAutoField(
                        help_text="API key issued by the DNS provider.", max_length=255
                    ),
                ),
                (
                    "api_secret",
                    core.fields.SigilShortAutoField(
                        help_text="API secret issued by the DNS provider.",
                        max_length=255,
                    ),
                ),
                (
                    "customer_id",
                    core.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Optional GoDaddy customer identifier for the account.",
                        max_length=100,
                    ),
                ),
                (
                    "default_domain",
                    core.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Fallback domain when records omit one.",
                        max_length=253,
                    ),
                ),
                (
                    "use_sandbox",
                    models.BooleanField(
                        default=False,
                        help_text="Use the GoDaddy OTE (test) environment.",
                    ),
                ),
                (
                    "is_enabled",
                    models.BooleanField(
                        default=True,
                        help_text="Disable to prevent deployments with this manager.",
                    ),
                ),
                (
                    "group",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="core.securitygroup",
                    ),
                ),
                (
                    "user",
                    models.OneToOneField(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Node Manager",
                "verbose_name_plural": "Node Managers",
            },
        ),
        migrations.CreateModel(
            name="DNSRecord",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                (
                    "provider",
                    models.CharField(
                        choices=[("godaddy", "GoDaddy")],
                        default="godaddy",
                        max_length=20,
                    ),
                ),
                (
                    "domain",
                    core.fields.SigilShortAutoField(
                        help_text="Base domain such as example.com.", max_length=253
                    ),
                ),
                (
                    "name",
                    core.fields.SigilShortAutoField(
                        help_text="Record host. Use @ for the zone apex.",
                        max_length=253,
                    ),
                ),
                (
                    "record_type",
                    models.CharField(
                        choices=[
                            ("A", "A"),
                            ("AAAA", "AAAA"),
                            ("CNAME", "CNAME"),
                            ("MX", "MX"),
                            ("NS", "NS"),
                            ("SRV", "SRV"),
                            ("TXT", "TXT"),
                        ],
                        default="A",
                        max_length=10,
                        verbose_name="Type",
                    ),
                ),
                (
                    "data",
                    core.fields.SigilLongAutoField(
                        help_text="Record value such as an IP address or hostname."
                    ),
                ),
                (
                    "ttl",
                    models.PositiveIntegerField(
                        default=600, help_text="Time to live in seconds."
                    ),
                ),
                (
                    "priority",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="Priority for MX and SRV records.",
                        null=True,
                    ),
                ),
                (
                    "port",
                    models.PositiveIntegerField(
                        blank=True, help_text="Port for SRV records.", null=True
                    ),
                ),
                (
                    "weight",
                    models.PositiveIntegerField(
                        blank=True, help_text="Weight for SRV records.", null=True
                    ),
                ),
                (
                    "service",
                    core.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Service label for SRV records (for example _sip).",
                        max_length=50,
                    ),
                ),
                (
                    "protocol",
                    core.fields.SigilShortAutoField(
                        blank=True,
                        help_text="Protocol label for SRV records (for example _tcp).",
                        max_length=10,
                    ),
                ),
                ("last_synced_at", models.DateTimeField(blank=True, null=True)),
                ("last_verified_at", models.DateTimeField(blank=True, null=True)),
                ("last_error", models.TextField(blank=True)),
                (
                    "node_manager",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="dns_records",
                        to="nodes.nodemanager",
                    ),
                ),
            ],
            options={
                "verbose_name": "DNS Record",
                "verbose_name_plural": "DNS Records",
            },
        ),
    ]
