# Generated by Django 5.2.9 on 2025-12-21 00:22

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


class Migration(migrations.Migration):

    dependencies = [
        ("ocpp", "0005_certificateoperation_certificaterequest_and_more"),
    ]

    operations = [
        migrations.CreateModel(
            name="MonitoringReport",
            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)),
                (
                    "request_id",
                    models.BigIntegerField(
                        blank=True, null=True, verbose_name="Request ID"
                    ),
                ),
                (
                    "seq_no",
                    models.BigIntegerField(
                        blank=True, null=True, verbose_name="Sequence Number"
                    ),
                ),
                (
                    "generated_at",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="Generated At"
                    ),
                ),
                (
                    "tbc",
                    models.BooleanField(default=False, verbose_name="To Be Continued"),
                ),
                ("raw_payload", models.JSONField(blank=True, default=dict)),
                (
                    "reported_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="Reported at"),
                ),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="monitoring_reports",
                        to="ocpp.charger",
                    ),
                ),
            ],
            options={
                "verbose_name": "Monitoring Report",
                "verbose_name_plural": "Monitoring Reports",
                "ordering": ["-reported_at", "-pk"],
            },
        ),
        migrations.CreateModel(
            name="Variable",
            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)),
                (
                    "component_name",
                    models.CharField(max_length=200, verbose_name="Component"),
                ),
                (
                    "component_instance",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=200,
                        verbose_name="Component Instance",
                    ),
                ),
                (
                    "variable_name",
                    models.CharField(max_length=200, verbose_name="Variable"),
                ),
                (
                    "variable_instance",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=200,
                        verbose_name="Variable Instance",
                    ),
                ),
                (
                    "attribute_type",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=32,
                        verbose_name="Attribute Type",
                    ),
                ),
                (
                    "attribute_status",
                    models.CharField(
                        blank=True,
                        default="",
                        max_length=32,
                        verbose_name="Attribute Status",
                    ),
                ),
                (
                    "value",
                    models.TextField(blank=True, default="", verbose_name="Value"),
                ),
                (
                    "value_type",
                    models.CharField(
                        blank=True, default="", max_length=32, verbose_name="Value Type"
                    ),
                ),
                (
                    "created_on",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created on"),
                ),
                (
                    "updated_on",
                    models.DateTimeField(auto_now=True, verbose_name="Updated on"),
                ),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ocpp_variables",
                        to="ocpp.charger",
                    ),
                ),
            ],
            options={
                "verbose_name": "Variable",
                "verbose_name_plural": "Variables",
                "ordering": ["component_name", "variable_name", "pk"],
            },
        ),
        migrations.CreateModel(
            name="MonitoringRule",
            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)),
                ("monitoring_id", models.BigIntegerField(verbose_name="Monitoring ID")),
                (
                    "severity",
                    models.PositiveIntegerField(
                        blank=True, null=True, verbose_name="Severity"
                    ),
                ),
                (
                    "monitor_type",
                    models.CharField(
                        blank=True, default="", max_length=32, verbose_name="Type"
                    ),
                ),
                (
                    "threshold",
                    models.CharField(
                        blank=True, default="", max_length=255, verbose_name="Threshold"
                    ),
                ),
                (
                    "is_transaction",
                    models.BooleanField(default=False, verbose_name="Transaction"),
                ),
                ("is_active", models.BooleanField(default=True, verbose_name="Active")),
                ("raw_payload", models.JSONField(blank=True, default=dict)),
                (
                    "created_on",
                    models.DateTimeField(auto_now_add=True, verbose_name="Created on"),
                ),
                (
                    "updated_on",
                    models.DateTimeField(auto_now=True, verbose_name="Updated on"),
                ),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="monitoring_rules",
                        to="ocpp.charger",
                    ),
                ),
                (
                    "variable",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="monitoring_rules",
                        to="ocpp.variable",
                    ),
                ),
            ],
            options={
                "verbose_name": "Monitoring Rule",
                "verbose_name_plural": "Monitoring Rules",
                "ordering": ["-updated_on", "monitoring_id", "pk"],
            },
        ),
        migrations.AddConstraint(
            model_name="variable",
            constraint=models.UniqueConstraint(
                fields=(
                    "charger",
                    "component_name",
                    "component_instance",
                    "variable_name",
                    "variable_instance",
                    "attribute_type",
                ),
                name="ocpp_variable_unique_component",
            ),
        ),
        migrations.AddConstraint(
            model_name="monitoringrule",
            constraint=models.UniqueConstraint(
                fields=("charger", "monitoring_id"),
                name="ocpp_monitoring_rule_unique_id",
            ),
        ),
    ]
