# Generated by Django 5.2.1 on 2026-02-28

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


class Migration(migrations.Migration):

    dependencies = [
        ("app", "0078_result_unique_assessment_student"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="StaffProfileExtra",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("national_id", models.CharField(blank=True, max_length=32)),
                ("passport_number", models.CharField(blank=True, max_length=32)),
                ("tin_number", models.CharField(blank=True, max_length=32)),
                ("next_of_kin_name", models.CharField(blank=True, max_length=120)),
                ("next_of_kin_contact", models.CharField(blank=True, max_length=30)),
                ("next_of_kin_relationship", models.CharField(blank=True, max_length=50)),
                ("emergency_contact_name", models.CharField(blank=True, max_length=120)),
                ("emergency_contact_phone", models.CharField(blank=True, max_length=30)),
                ("emergency_contact_relationship", models.CharField(blank=True, max_length=50)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "staff",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hr_profile",
                        to="app.staff",
                    ),
                ),
            ],
            options={
                "verbose_name": "Staff profile extra",
                "verbose_name_plural": "Staff profile extras",
                "ordering": ("-updated_at", "-id"),
            },
        ),
        migrations.CreateModel(
            name="StaffCertification",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=160)),
                ("issuer", models.CharField(blank=True, max_length=160)),
                ("certification_number", models.CharField(blank=True, max_length=80)),
                ("issue_date", models.DateField(blank=True, null=True)),
                ("expiry_date", models.DateField(blank=True, null=True)),
                ("document_file", models.FileField(blank=True, null=True, upload_to="Staff/HR/Certifications")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "staff",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hr_certifications",
                        to="app.staff",
                    ),
                ),
            ],
            options={
                "ordering": ("-issue_date", "-id"),
                "constraints": [
                    models.UniqueConstraint(
                        fields=("staff", "name", "issuer", "certification_number"),
                        name="uniq_staff_certification_record",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="StaffHRDocument",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "category",
                    models.CharField(
                        choices=[
                            ("contract", "Contract"),
                            ("appointment", "Appointment Letter"),
                            ("promotion", "Promotion Letter"),
                            ("payslip", "Payslip"),
                            ("certificate", "Certificate"),
                            ("disciplinary", "Disciplinary"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=20,
                    ),
                ),
                ("title", models.CharField(max_length=180)),
                ("file", models.FileField(upload_to="Staff/HR/Documents")),
                (
                    "visibility",
                    models.CharField(
                        choices=[
                            ("hr_only", "HR only"),
                            ("owner_and_hr", "Owner and HR"),
                            ("owner_only", "Owner only"),
                        ],
                        default="hr_only",
                        max_length=20,
                    ),
                ),
                ("is_confidential", models.BooleanField(default=True)),
                ("expires_on", models.DateField(blank=True, null=True)),
                ("notes", models.TextField(blank=True)),
                ("verified_at", models.DateTimeField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "staff",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hr_documents",
                        to="app.staff",
                    ),
                ),
                (
                    "uploaded_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="uploaded_staff_hr_documents",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "verified_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="verified_staff_hr_documents",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("-created_at", "-id"),
                "indexes": [
                    models.Index(fields=["staff", "category"], name="app_staffhrd_staff_i_2925d4_idx"),
                    models.Index(fields=["visibility"], name="app_staffhrd_visibil_7ab441_idx"),
                    models.Index(fields=["expires_on"], name="app_staffhrd_expires_1531f2_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="StaffLicense",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "license_type",
                    models.CharField(
                        choices=[
                            ("teaching", "Teaching License"),
                            ("professional", "Professional License"),
                            ("practising", "Practising License"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=20,
                    ),
                ),
                ("license_number", models.CharField(max_length=80)),
                ("issuing_authority", models.CharField(blank=True, max_length=160)),
                ("issue_date", models.DateField(blank=True, null=True)),
                ("expiry_date", models.DateField(blank=True, null=True)),
                ("document_file", models.FileField(blank=True, null=True, upload_to="Staff/HR/Licenses")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "staff",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hr_licenses",
                        to="app.staff",
                    ),
                ),
            ],
            options={
                "ordering": ("-issue_date", "-id"),
                "constraints": [
                    models.UniqueConstraint(fields=("staff", "license_number"), name="uniq_staff_license_number")
                ],
            },
        ),
        migrations.CreateModel(
            name="StaffQualification",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "level",
                    models.CharField(
                        choices=[
                            ("certificate", "Certificate"),
                            ("diploma", "Diploma"),
                            ("bachelors", "Bachelor's"),
                            ("masters", "Master's"),
                            ("phd", "PhD"),
                            ("other", "Other"),
                        ],
                        default="other",
                        max_length=20,
                    ),
                ),
                ("award_title", models.CharField(max_length=160)),
                ("institution", models.CharField(blank=True, max_length=160)),
                ("year_awarded", models.PositiveSmallIntegerField(blank=True, null=True)),
                ("document_file", models.FileField(blank=True, null=True, upload_to="Staff/HR/Qualifications")),
                ("verified_at", models.DateTimeField(blank=True, null=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "staff",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="hr_qualifications",
                        to="app.staff",
                    ),
                ),
                (
                    "verified_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="verified_staff_qualifications",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("-year_awarded", "-id"),
                "constraints": [
                    models.UniqueConstraint(
                        fields=("staff", "award_title", "institution", "year_awarded"),
                        name="uniq_staff_qualification_record",
                    )
                ],
            },
        ),
        migrations.CreateModel(
            name="EmploymentRecord",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("staff_id_code", models.CharField(blank=True, max_length=40)),
                ("job_title", models.CharField(max_length=120)),
                (
                    "department",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("Student", "Student"),
                            ("Academic", "Academic"),
                            ("Finance", "Finance"),
                            ("Administration", "Administration"),
                            ("Security", "Security"),
                            ("Transport", "Transport"),
                            ("Support", "Support"),
                        ],
                        max_length=30,
                    ),
                ),
                (
                    "employment_type",
                    models.CharField(
                        choices=[
                            ("full_time", "Full-time"),
                            ("contract", "Contract"),
                            ("part_time", "Part-time"),
                        ],
                        default="full_time",
                        max_length=20,
                    ),
                ),
                (
                    "status",
                    models.CharField(
                        choices=[
                            ("active", "Active"),
                            ("on_leave", "On Leave"),
                            ("suspended", "Suspended"),
                            ("exited", "Exited"),
                        ],
                        default="active",
                        max_length=20,
                    ),
                ),
                ("hire_date", models.DateField()),
                ("effective_start", models.DateField()),
                ("effective_end", models.DateField(blank=True, null=True)),
                ("probation_end", models.DateField(blank=True, null=True)),
                ("is_current", models.BooleanField(default=True)),
                ("notes", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "reporting_to",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="staff_reporting_lines",
                        to="app.staff",
                    ),
                ),
                (
                    "staff",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="employment_records",
                        to="app.staff",
                    ),
                ),
            ],
            options={
                "ordering": ("-is_current", "-effective_start", "-id"),
                "indexes": [
                    models.Index(fields=["staff", "is_current"], name="app_employme_staff_i_e98eaf_idx"),
                    models.Index(fields=["status"], name="app_employme_status_c9a6aa_idx"),
                    models.Index(fields=["effective_end"], name="app_employme_effecti_93237b_idx"),
                    models.Index(fields=["staff_id_code"], name="app_employme_staff_i_19f44b_idx"),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        condition=models.Q(("is_current", True)),
                        fields=("staff",),
                        name="uniq_current_employment_per_staff",
                    )
                ],
            },
        ),
    ]
