# Generated by Django 5.2.6 on 2026-04-08 02:04

import django.db.models.deletion
import routine.models
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("batch", "0001_initial"),
        ("batch_year", "0001_initial"),
        ("classroom", "0001_initial"),
        ("course", "0002_initial"),
        ("days", "0001_initial"),
        ("departments", "0001_initial"),
        ("organization", "0001_initial"),
        ("semester", "0001_initial"),
        ("status", "__first__"),
    ]

    operations = [
        migrations.CreateModel(
            name="Routine",
            fields=[
                (
                    "is_global",
                    models.BooleanField(
                        default=False,
                        help_text="If true, this data is shared across all organizations.",
                    ),
                ),
                ("id", models.AutoField(primary_key=True, serialize=False)),
                ("name", models.CharField(max_length=255, unique=True)),
                ("slug", models.SlugField(max_length=255, unique=True)),
                ("routine_year", models.IntegerField(blank=True, null=True)),
                ("effective_from", models.DateField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "batch",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routines",
                        to="batch.batch",
                    ),
                ),
                (
                    "department",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routines",
                        to="departments.department",
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)s_data",
                        to="organization.organization",
                    ),
                ),
                (
                    "semester",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routines",
                        to="semester.semester",
                    ),
                ),
                (
                    "status",
                    models.ForeignKey(
                        blank=True,
                        default=routine.models.get_draft_status,
                        limit_choices_to={"type": "routine"},
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="status.status",
                    ),
                ),
                (
                    "year",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routines",
                        to="batch_year.batchyear",
                    ),
                ),
            ],
            options={
                "verbose_name": "Routine",
                "verbose_name_plural": "Routines",
                "ordering": ["batch", "semester", "year", "department"],
            },
        ),
        migrations.CreateModel(
            name="RoutineData",
            fields=[
                (
                    "is_global",
                    models.BooleanField(
                        default=False,
                        help_text="If true, this data is shared across all organizations.",
                    ),
                ),
                ("id", models.AutoField(primary_key=True, serialize=False)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "course",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routine_entries",
                        to="course.course",
                    ),
                ),
                (
                    "day_of_week",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routines",
                        to="days.day",
                    ),
                ),
                (
                    "organization",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="%(class)s_data",
                        to="organization.organization",
                    ),
                ),
                (
                    "room",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="routine_entries",
                        to="classroom.classroom",
                    ),
                ),
                (
                    "routine",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="routine_data",
                        to="routine.routine",
                    ),
                ),
                (
                    "status",
                    models.ForeignKey(
                        default=routine.models.get_available_status,
                        limit_choices_to={"type": "routine_data"},
                        on_delete=django.db.models.deletion.CASCADE,
                        to="status.status",
                    ),
                ),
            ],
            options={
                "verbose_name": "Routine Data",
                "verbose_name_plural": "Routine Data",
                "db_table": "routine_data",
                "ordering": ["routine", "time_slot"],
            },
        ),
    ]
