# Generated by Django 5.2.17 on 2026-10-02 11:47

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


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0008_systemstate'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CorrectionLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('kind', models.CharField(choices=[('DEMO', 'Student demographics (name, father, phone, tier, class)'), ('REPORT', 'Report field correction (score, band, mistakes, reflection)'), ('ATTEND', 'Attendance correction'), ('TASK', 'Daily task correction'), ('STORY', 'Story lecture correction'), ('PROFILE', 'Student profile entry correction')], db_index=True, max_length=8)),
                ('target_model', models.CharField(max_length=40)),
                ('target_id', models.PositiveIntegerField(db_index=True)),
                ('field_name', models.CharField(max_length=60)),
                ('old_value', models.TextField(blank=True)),
                ('new_value', models.TextField(blank=True)),
                ('reason', models.TextField(help_text='Why this correction was made.')),
                ('actor_label', models.CharField(blank=True, help_text='Fallback when actor FK is null, e.g. terminal:teacher', max_length=60)),
                ('created_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('actor', models.ForeignKey(blank=True, help_text='Who made the change. Null = system.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='corrections_made', to=settings.AUTH_USER_MODEL)),
                ('student', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='corrections', to='exams.student')),
            ],
            options={
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['target_model', 'target_id'], name='exams_corre_target__67bf86_idx'), models.Index(fields=['kind', 'created_at'], name='exams_corre_kind_6b0a12_idx')],
            },
        ),
    ]
