# Generated by Django 5.2.8 on 2025-11-24 13:29

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("nodes", "0047_remove_roleconfigurationprofile_role_and_more"),
        ("ocpp", "0064_transaction_ocpp_transaction_id"),
    ]

    operations = [
        migrations.CreateModel(
            name="CPNetworkProfile",
            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)),
                ("name", models.CharField(max_length=200, verbose_name="Name")),
                (
                    "description",
                    models.TextField(blank=True, verbose_name="Description"),
                ),
                (
                    "configuration_slot",
                    models.PositiveIntegerField(
                        default=1,
                        help_text="Target configurationSlot.",
                        verbose_name="Configuration slot",
                    ),
                ),
                (
                    "connection_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="connectionData payload for SetNetworkProfile.",
                    ),
                ),
                (
                    "apn",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Optional APN settings to include with the profile.",
                    ),
                ),
                (
                    "vpn",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Optional VPN settings to include with the profile.",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "CP Network Profile",
                "verbose_name_plural": "CP Network Profiles",
                "ordering": ["name", "configuration_slot"],
            },
        ),
        migrations.AddField(
            model_name="charger",
            name="network_profile",
            field=models.ForeignKey(
                blank=True,
                help_text="Last network profile that was successfully applied to this charge point.",
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="chargers",
                to="ocpp.cpnetworkprofile",
            ),
        ),
        migrations.CreateModel(
            name="CPNetworkProfileDeployment",
            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)),
                (
                    "ocpp_message_id",
                    models.CharField(
                        blank=True, max_length=64, verbose_name="OCPP message ID"
                    ),
                ),
                (
                    "status",
                    models.CharField(blank=True, max_length=32, verbose_name="Status"),
                ),
                (
                    "status_info",
                    models.CharField(
                        blank=True, max_length=255, verbose_name="Status details"
                    ),
                ),
                (
                    "status_timestamp",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Status timestamp"
                    ),
                ),
                (
                    "requested_at",
                    models.DateTimeField(
                        auto_now_add=True, verbose_name="Requested at"
                    ),
                ),
                (
                    "completed_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Completed at"
                    ),
                ),
                ("request_payload", models.JSONField(blank=True, default=dict)),
                ("response_payload", models.JSONField(blank=True, default=dict)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="network_profile_deployments",
                        to="ocpp.charger",
                        verbose_name="Charge point",
                    ),
                ),
                (
                    "network_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="deployments",
                        to="ocpp.cpnetworkprofile",
                        verbose_name="Network profile",
                    ),
                ),
                (
                    "node",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="network_profile_deployments",
                        to="nodes.node",
                        verbose_name="Node",
                    ),
                ),
            ],
            options={
                "verbose_name": "CP Network Profile Deployment",
                "verbose_name_plural": "CP Network Profile Deployments",
                "ordering": ["-requested_at"],
                "indexes": [
                    models.Index(
                        fields=["ocpp_message_id"],
                        name="ocpp_cpnetw_ocpp_me_cc48cb_idx",
                    )
                ],
            },
        ),
    ]
