# Generated by Django 5.2.7 on 2025-11-08 23:12

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


class Migration(migrations.Migration):

    dependencies = [
        ("ocpp", "0041_alter_cpfirmwaredeployment_options"),
    ]

    operations = [
        migrations.CreateModel(
            name="ChargerLogRequest",
            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(
                        default=ocpp.models.generate_log_request_id,
                        unique=True,
                        verbose_name="Request Id",
                    ),
                ),
                ("message_id", models.CharField(blank=True, default="", max_length=64)),
                ("log_type", models.CharField(blank=True, default="", max_length=64)),
                ("status", models.CharField(blank=True, default="", max_length=32)),
                ("filename", models.CharField(blank=True, default="", max_length=255)),
                ("location", models.CharField(blank=True, default="", max_length=500)),
                (
                    "session_key",
                    models.CharField(blank=True, default="", max_length=200),
                ),
                ("requested_at", models.DateTimeField(auto_now_add=True)),
                ("responded_at", models.DateTimeField(blank=True, null=True)),
                ("last_status_at", models.DateTimeField(blank=True, null=True)),
                ("raw_response", models.JSONField(blank=True, default=dict)),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="log_requests",
                        to="ocpp.charger",
                    ),
                ),
            ],
            options={
                "verbose_name": "Log Request",
                "verbose_name_plural": "Log Requests",
                "ordering": ["-requested_at", "-pk"],
            },
        ),
        migrations.CreateModel(
            name="ChargerLogStatus",
            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)),
                ("status", models.CharField(max_length=32)),
                ("log_type", models.CharField(blank=True, default="", max_length=64)),
                ("occurred_at", models.DateTimeField()),
                ("raw_payload", models.JSONField(blank=True, default=dict)),
                (
                    "request",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="status_updates",
                        to="ocpp.chargerlogrequest",
                    ),
                ),
            ],
            options={
                "verbose_name": "Log Status Event",
                "verbose_name_plural": "Log Status Events",
                "ordering": ["-occurred_at", "-pk"],
            },
        ),
        migrations.CreateModel(
            name="SecurityEvent",
            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)),
                (
                    "event_type",
                    models.CharField(max_length=120, verbose_name="Event Type"),
                ),
                (
                    "event_timestamp",
                    models.DateTimeField(verbose_name="Event Timestamp"),
                ),
                ("trigger", models.CharField(blank=True, default="", max_length=120)),
                ("tech_info", models.TextField(blank=True, default="")),
                ("sequence_number", models.BigIntegerField(blank=True, null=True)),
                ("raw_payload", models.JSONField(blank=True, default=dict)),
                ("reported_at", models.DateTimeField(auto_now_add=True)),
                (
                    "charger",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="security_events",
                        to="ocpp.charger",
                    ),
                ),
            ],
            options={
                "verbose_name": "Security Event",
                "verbose_name_plural": "Security Events",
                "ordering": ["-event_timestamp", "-pk"],
            },
        ),
    ]
