# Generated by Django 5.2.17 on 2026-10-11 18:43

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


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0062_correctionlog_kind_firewall'),
    ]

    operations = [
        migrations.CreateModel(
            name='DataQualityIssue',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('severity', models.CharField(choices=[('BLOCKER', 'Blocking downstream work'), ('MAJOR', 'Affects quality materially'), ('MINOR', 'Cosmetic / non-blocking')], db_index=True, max_length=10)),
                ('defect_class', models.CharField(choices=[('MISSING', 'Required field is null / blank'), ('WRONG', 'Semantic check fails'), ('INCONSISTENT', 'Same construct, conflicting values'), ('DUPLICATE', 'Same content, multiple rows'), ('MALFORMED', 'Shape violates schema'), ('ORPHAN', 'Foreign key points to nothing')], db_index=True, max_length=15)),
                ('entity_type', models.CharField(db_index=True, max_length=40)),
                ('entity_id', models.PositiveIntegerField(db_index=True)),
                ('evidence', models.JSONField(blank=True, default=dict, help_text='Raw defective content + context for the correction prompt.')),
                ('status', models.CharField(choices=[('OPEN', 'Detected, not yet assigned'), ('TASK_ASSIGNED', 'Correction task created'), ('IN_PROGRESS', 'Student working on it'), ('VERIFIED', 'Correction verified'), ('CLOSED', 'Resolved (new row supersedes old)'), ('ESCALATED', 'Routed to teacher queue')], db_index=True, default='OPEN', max_length=15)),
                ('detected_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('detected_by', models.CharField(default='detect_kc_defects', max_length=60)),
                ('superseded_at', models.DateTimeField(blank=True, null=True)),
                ('resolved_at', models.DateTimeField(blank=True, null=True)),
                ('resolved_by_task', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='dq_issues', to='exams.studenttask')),
            ],
            options={
                'ordering': ['-detected_at'],
                'indexes': [models.Index(fields=['entity_type', 'entity_id'], name='exams_dataq_entity__a1a5d7_idx'), models.Index(fields=['status', 'severity'], name='exams_dataq_status_66cb01_idx')],
            },
        ),
    ]
