# Generated by Django 5.2.17 on 2026-10-07 10:56

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


class Migration(migrations.Migration):

    dependencies = [
        ('exams', '0024_exam_model_question_link'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PortalFeature',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(max_length=80, unique=True)),
                ('enabled', models.BooleanField(default=False)),
                ('message', models.TextField(blank=True)),
                ('allocation_policy', models.CharField(choices=[('EXCLUSIVE', 'Exclusive - one student per task_ref'), ('SHARED', 'Shared - duplicates allowed')], default='EXCLUSIVE', max_length=12)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('updated_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='portal_features_updated', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='PortalFeatureLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('key', models.CharField(db_index=True, max_length=80)),
                ('old_enabled', models.BooleanField()),
                ('new_enabled', models.BooleanField()),
                ('changed_at', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('note', models.TextField(blank=True)),
                ('changed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='portal_feature_logs', to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='StudentTask',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('task_type', models.CharField(choices=[('BOOK_INGEST', 'Book page-pair ingest'), ('KC_MISCONCEPTION', 'KC misconception generation'), ('KC_TAG', 'KC tagging'), ('KC_SOCRATIC_LADDER', 'KC socratic ladder'), ('GLOSSARY', 'Glossary entries'), ('STORY', 'Story lecture')], db_index=True, max_length=24)),
                ('task_ref', models.CharField(db_index=True, max_length=120)),
                ('status', models.CharField(choices=[('ASSIGNED', 'Assigned'), ('IN_PROGRESS', 'In progress'), ('DONE', 'Done'), ('SKIPPED', 'Skipped')], db_index=True, default='ASSIGNED', max_length=12)),
                ('assigned_at', models.DateTimeField(auto_now_add=True)),
                ('completed_at', models.DateTimeField(blank=True, null=True)),
                ('json_payload', models.JSONField(blank=True, null=True)),
                ('ingest_status', models.CharField(choices=[('PENDING', 'Pending'), ('OK', 'OK'), ('FAILED', 'Failed')], db_index=True, default='PENDING', max_length=10)),
                ('ingest_error', models.TextField(blank=True)),
                ('idempotency_key', models.CharField(blank=True, db_index=True, max_length=64)),
                ('last_heartbeat_at', models.DateTimeField(blank=True, null=True)),
                ('notes', models.TextField(blank=True)),
                ('assigned_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='student_tasks_assigned', to=settings.AUTH_USER_MODEL)),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student_tasks', to='exams.student')),
            ],
            options={
                'indexes': [models.Index(fields=['student', 'status'], name='exams_stude_student_391611_idx'), models.Index(fields=['task_type', 'status'], name='exams_stude_task_ty_adb79d_idx')],
            },
        ),
    ]
