# Generated by Django 6.0.3 on 2026-04-28 11:12

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("users", "0003_user_email_case_insensitive_unique"),
    ]

    operations = [
        migrations.CreateModel(
            name="AuditLog",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "method",
                    models.CharField(
                        help_text="HTTP method (e.g., GET, POST)", max_length=10
                    ),
                ),
                (
                    "path",
                    models.CharField(help_text="Requested URL path", max_length=255),
                ),
                (
                    "payload",
                    models.JSONField(
                        blank=True, help_text="Request payload data", null=True
                    ),
                ),
                (
                    "status_code",
                    models.IntegerField(
                        blank=True, help_text="HTTP response status code", null=True
                    ),
                ),
                (
                    "ip_address",
                    models.GenericIPAddressField(
                        blank=True, help_text="IP address of the user", null=True
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        help_text="The user who performed the action.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="audit_logs",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Audit Log",
                "verbose_name_plural": "Audit Logs",
                "db_table": "users_audit_log",
                "ordering": ["-created_at"],
            },
        ),
    ]
