# Generated by Django 4.2.23 on 2026-02-15 00:00

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


class Migration(migrations.Migration):

    dependencies = [
        ("aa_bb", "0114_bigbrotherconfig_webhook_app_name"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterModelOptions(
            name="general",
            options={
                "default_permissions": (),
                "managed": False,
                "permissions": (
                    ("basic_access", "Can access Big Brother"),
                    ("full_access", "Can view all main characters in Big Brother"),
                    ("recruiter_access", "Can view main characters in Guest state only in Big Brother"),
                    ("basic_access_cb", "Can access Corp Brother"),
                    ("full_access_cb", "Can view all corps in Corp Brother"),
                    ("recruiter_access_cb", "Can view guest's corps only in Corp Brother"),
                    ("can_blacklist_characters", "Can add characters to blacklist"),
                    ("can_access_loa", "Can access and submit a Leave Of Absence request"),
                    ("can_view_all_loa", "Can view all Leave Of Absence requests"),
                    ("can_manage_loa", "Can manage Leave Of Absence requests"),
                    ("can_access_paps", "Can access PAP Stats"),
                    ("can_generate_paps", "Can generate PAP Stats"),
                    ("ticket_manager", "Can manage compliance tickets"),
                ),
            },
        ),
        migrations.CreateModel(
            name="AdminLogEntry",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("category", models.CharField(choices=[("state", "State Change"), ("group", "Group Change"), ("discord", "Discord Change"), ("admin", "Admin Action"), ("auth", "Auth Change"), ("system", "System"), ("other", "Other")], db_index=True, max_length=32)),
                ("action", models.CharField(db_index=True, max_length=64)),
                ("source", models.CharField(blank=True, db_index=True, default="", max_length=64)),
                ("task_name", models.CharField(blank=True, db_index=True, default="", max_length=128)),
                ("reason", models.TextField(blank=True, default="")),
                ("target_label", models.CharField(blank=True, default="", max_length=255)),
                ("message", models.TextField(blank=True, default="")),
                ("metadata", models.JSONField(blank=True, default=dict)),
                ("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
                ("actor", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="admin_log_entries", to=settings.AUTH_USER_MODEL)),
                ("target_user", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="admin_log_targets", to=settings.AUTH_USER_MODEL)),
            ],
            options={
                "verbose_name": "Admin Log Entry",
                "verbose_name_plural": "Admin Log Entries",
                "ordering": ["-created_at"],
            },
        ),
        migrations.AddIndex(
            model_name="adminlogentry",
            index=models.Index(fields=["category", "action"], name="aa_bb_adminlog_cat_action_idx"),
        ),
        migrations.AddIndex(
            model_name="adminlogentry",
            index=models.Index(fields=["source", "task_name"], name="aa_bb_adminlog_source_task_idx"),
        ),
        migrations.AddIndex(
            model_name="adminlogentry",
            index=models.Index(fields=["actor"], name="aa_bb_adminlog_actor_idx"),
        ),
        migrations.AddIndex(
            model_name="adminlogentry",
            index=models.Index(fields=["target_user"], name="aa_bb_adminlog_target_idx"),
        ),
        migrations.AddIndex(
            model_name="adminlogentry",
            index=models.Index(fields=["created_at"], name="aa_bb_adminlog_created_idx"),
        ),
    ]
