# Generated by Django 6.0 on 2026-02-04 17:11

import django.core.validators
import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('people', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='AcademicYear',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=20, unique=True)),
                ('code', models.CharField(blank=True, max_length=10, null=True, unique=True)),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('terms_count', models.PositiveIntegerField(default=2, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(4)])),
                ('fee_due_date', models.DateField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=False)),
                ('is_frozen', models.BooleanField(default=False)),
                ('admissions_open', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Section',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=10, unique=True)),
                ('description', models.TextField(blank=True)),
                ('capacity', models.PositiveIntegerField(default=40, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100)])),
                ('section_type', models.CharField(blank=True, choices=[('REGULAR', 'Regular'), ('SPECIAL_NEEDS', 'Special Needs'), ('HONORS', 'Honors'), ('GIFTED', 'Gifted'), ('ATHLETIC', 'Athletic')], max_length=20, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='Standard',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('code', models.CharField(max_length=20, unique=True)),
                ('order', models.PositiveIntegerField(unique=True)),
                ('standard_type', models.CharField(choices=[('nursery', 'Nursery'), ('kg', 'KG'), ('primary', 'Primary'), ('secondary', 'Secondary'), ('higher_secondary', 'Higher Secondary')], max_length=20)),
                ('description', models.TextField(blank=True)),
                ('min_age', models.PositiveIntegerField(blank=True, null=True)),
                ('max_age', models.PositiveIntegerField(blank=True, null=True)),
                ('min_subjects', models.PositiveIntegerField(default=5)),
                ('max_subjects', models.PositiveIntegerField(default=10)),
                ('passing_percentage', models.DecimalField(decimal_places=2, default=35, max_digits=5)),
                ('tuition_fee', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='SubjectCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
                ('code', models.CharField(max_length=20, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='AcademicClass',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('room_number', models.CharField(blank=True, max_length=20)),
                ('timetable_document', models.FileField(blank=True, null=True, upload_to='academic_classes/timetables/')),
                ('current_strength', models.PositiveIntegerField(default=0)),
                ('max_strength', models.PositiveIntegerField(default=40, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100)])),
                ('boys_count', models.PositiveIntegerField(default=0)),
                ('girls_count', models.PositiveIntegerField(default=0)),
                ('annual_fee', models.DecimalField(blank=True, decimal_places=2, max_digits=10, null=True)),
                ('passing_percentage', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True)),
                ('min_attendance_percentage', models.DecimalField(decimal_places=2, default=75.0, max_digits=5)),
                ('is_active', models.BooleanField(default=True)),
                ('is_frozen', models.BooleanField(default=False)),
                ('notes', models.TextField(blank=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('assistant_teacher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assistant_teacher_classes', to='people.teacher')),
                ('class_teacher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='class_teacher_classes', to='people.teacher')),
                ('academic_year', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='classes', to='academics.academicyear')),
                ('section', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='classes', to='academics.section')),
                ('standard', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='classes', to='academics.standard')),
            ],
        ),
        migrations.CreateModel(
            name='StudentEnrollment',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('roll_number', models.PositiveIntegerField()),
                ('admission_date', models.DateField(blank=True, null=True)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('academic_class', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='enrollments', to='academics.academicclass')),
                ('student', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='enrollments', to='people.student')),
            ],
            options={
                'unique_together': {('student', 'academic_class')},
            },
        ),
        migrations.CreateModel(
            name='SubjectGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=20, unique=True)),
                ('is_active', models.BooleanField(default=True)),
                ('standard', models.ForeignKey(limit_choices_to={'standard_type': 'higher_secondary'}, on_delete=django.db.models.deletion.CASCADE, related_name='subject_groups', to='academics.standard')),
            ],
            options={
                'unique_together': {('standard', 'name')},
            },
        ),
        migrations.CreateModel(
            name='Subject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=20)),
                ('subject_type', models.CharField(choices=[('mandatory', 'Mandatory'), ('elective', 'Elective'), ('language', 'Language')], default='mandatory', max_length=20)),
                ('is_active', models.BooleanField(default=True)),
                ('standard', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subjects', to='academics.standard')),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subjects', to='academics.subjectcategory')),
                ('subject_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subjects', to='academics.subjectgroup')),
            ],
            options={
                'unique_together': {('standard', 'code')},
            },
        ),
        migrations.AddField(
            model_name='academicclass',
            name='subject_group',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='academics.subjectgroup'),
        ),
        migrations.CreateModel(
            name='AcademicTerm',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('code', models.CharField(max_length=20)),
                ('order', models.PositiveIntegerField()),
                ('start_date', models.DateField()),
                ('end_date', models.DateField()),
                ('is_exam_term', models.BooleanField(default=False)),
                ('weightage', models.DecimalField(decimal_places=2, default=100.0, max_digits=5)),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('academic_year', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='terms', to='academics.academicyear')),
            ],
            options={
                'unique_together': {('academic_year', 'code'), ('academic_year', 'order')},
            },
        ),
        migrations.CreateModel(
            name='StudentSubject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('enrollment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='selected_subjects', to='academics.studentenrollment')),
                ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='students', to='academics.subject')),
            ],
            options={
                'unique_together': {('enrollment', 'subject')},
            },
        ),
        migrations.CreateModel(
            name='ClassSubject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('academic_class', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='class_subjects', to='academics.academicclass')),
                ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='class_subjects', to='academics.subject')),
            ],
            options={
                'unique_together': {('academic_class', 'subject')},
            },
        ),
        migrations.CreateModel(
            name='StudentSubjectGroup',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('enrollment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject_groups', to='academics.studentenrollment')),
                ('subject_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='student_enrollments', to='academics.subjectgroup')),
            ],
            options={
                'unique_together': {('enrollment', 'subject_group')},
            },
        ),
        migrations.AlterUniqueTogether(
            name='academicclass',
            unique_together={('academic_year', 'standard', 'section')},
        ),
        migrations.CreateModel(
            name='SubjectTeacher',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('academic_class', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject_teachers', to='academics.academicclass')),
                ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject_teachers', to='academics.subject')),
                ('teacher', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subject_teachers', to='people.teacher')),
            ],
            options={
                'unique_together': {('academic_class', 'subject')},
            },
        ),
    ]
