# Generated by Django 5.2.9 on 2026-01-06 22:20

import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("core", "0006_delete_admincommandresult"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="UsageEvent",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(
                        db_index=True, default=django.utils.timezone.now
                    ),
                ),
                ("app_label", models.CharField(db_index=True, max_length=100)),
                ("view_name", models.CharField(db_index=True, max_length=255)),
                ("path", models.TextField()),
                ("method", models.CharField(max_length=10)),
                ("status_code", models.PositiveIntegerField()),
                (
                    "model_label",
                    models.CharField(blank=True, default="", max_length=255),
                ),
                (
                    "action",
                    models.CharField(
                        choices=[
                            ("read", "Read"),
                            ("create", "Create"),
                            ("update", "Update"),
                            ("delete", "Delete"),
                        ],
                        db_index=True,
                        default="read",
                        max_length=12,
                    ),
                ),
                ("metadata", models.JSONField(blank=True, default=dict)),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="usage_events",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ["-timestamp"],
                "indexes": [
                    models.Index(
                        fields=["app_label", "view_name", "timestamp"],
                        name="core_usagee_app_lab_e90cdc_idx",
                    )
                ],
            },
        ),
    ]
