# Generated by Django 5.2.7 on 2025-10-29 10:49

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="HoneyGuardLog",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "ip_address",
                    models.GenericIPAddressField(
                        db_index=True, help_text="IP address of the requester"
                    ),
                ),
                (
                    "path",
                    models.CharField(
                        db_index=True, help_text="URL path accessed", max_length=255
                    ),
                ),
                (
                    "username",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Username submitted in login attempt",
                        max_length=255,
                    ),
                ),
                (
                    "password",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Password submitted in login attempt",
                        max_length=255,
                    ),
                ),
                (
                    "user_agent",
                    models.TextField(
                        blank=True,
                        default="",
                        help_text="User agent string from request",
                    ),
                ),
                (
                    "referer",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="HTTP referer header",
                        max_length=500,
                    ),
                ),
                (
                    "accept_language",
                    models.CharField(blank=True, default="", max_length=255),
                ),
                (
                    "accept_encoding",
                    models.CharField(blank=True, default="", max_length=255),
                ),
                (
                    "method",
                    models.CharField(
                        choices=[("GET", "GET"), ("POST", "POST")],
                        default="POST",
                        max_length=10,
                    ),
                ),
                (
                    "honeypot_triggered",
                    models.BooleanField(
                        db_index=True,
                        default=False,
                        help_text="Whether the honeypot field was filled",
                    ),
                ),
                (
                    "timing_issue",
                    models.CharField(
                        choices=[
                            ("too_fast", "Too Fast"),
                            ("too_slow", "Too Slow"),
                            ("valid", "Valid Timing"),
                        ],
                        default="valid",
                        help_text="Type of timing anomaly detected",
                        max_length=20,
                    ),
                ),
                (
                    "elapsed_time",
                    models.FloatField(
                        blank=True,
                        help_text="Time in seconds between form render and submission",
                        null=True,
                    ),
                ),
                (
                    "raw_metadata",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Raw request metadata for debugging",
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "HoneyGuard Log",
                "verbose_name_plural": "HoneyGuard Logs",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(
                        fields=["-created_at", "ip_address"],
                        name="django_hone_created_f6071c_idx",
                    ),
                    models.Index(
                        fields=["honeypot_triggered", "-created_at"],
                        name="django_hone_honeypo_186767_idx",
                    ),
                    models.Index(
                        fields=["path", "-created_at"],
                        name="django_hone_path_b7dc5f_idx",
                    ),
                ],
            },
        ),
    ]
