# Generated by Django 5.2.17 on 2026-10-15 17:09

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


class Migration(migrations.Migration):

    dependencies = [
        ('academy', '0010_academysetting_portal_enabled_and_more'),
        ('discipline', '0002_discipline_delegation'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='DisciplineAuditEvent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.CharField(choices=[('DELEGATION_GRANTED', 'Delegation granted'), ('DELEGATION_REVOKED', 'Delegation revoked'), ('DELEGATION_EXPIRED', 'Delegation expired'), ('DELEGATED_WRITE', 'Delegated write'), ('DENIED_WRITE', 'Denied write'), ('READ_OWN', 'Read own record')], max_length=32)),
                ('target_model', models.CharField(blank=True, default='', max_length=64)),
                ('target_id', models.PositiveBigIntegerField(blank=True, null=True)),
                ('payload_hash', models.CharField(blank=True, default='', max_length=64)),
                ('detail', models.TextField(blank=True, default='')),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('actor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='discipline_audit_events', to=settings.AUTH_USER_MODEL)),
                ('delegation', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='audit_events', to='discipline.disciplinedelegation')),
                ('target_student', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='discipline_audit_events', to='academy.academystudent')),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['actor', 'created_at'], name='dae_actor_idx'), models.Index(fields=['action', 'created_at'], name='dae_action_idx'), models.Index(fields=['target_student', 'created_at'], name='dae_student_idx')],
            },
        ),
    ]
