# Generated by Django 5.2.8 on 2026-04-10 02:39

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("basic_info", "0025_customer_uniq_customer_merchant_name"),
        ("contenttypes", "0002_remove_content_type_name"),
    ]

    operations = [
        migrations.CreateModel(
            name="Mission",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                ("description", models.TextField(verbose_name="任务描述")),
                ("category", models.CharField(choices=[("general", "通用")], db_index=True, default="general", max_length=50, verbose_name="任务类型")),
                ("is_urgent", models.BooleanField(db_index=True, default=False, verbose_name="是否紧急")),
                ("is_completed", models.BooleanField(db_index=True, default=False, verbose_name="是否完成")),
                ("is_cancelled", models.BooleanField(db_index=True, default=False, verbose_name="是否取消")),
                ("cancelled_at", models.DateTimeField(blank=True, null=True, verbose_name="取消时间")),
                ("content_id", models.PositiveBigIntegerField(blank=True, db_index=True, null=True, verbose_name="关联对象ID")),
                ("cancelled_by", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name="cancelled_missions", to="basic_info.employee", verbose_name="取消人")),
                ("content_type", models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="missions", to="contenttypes.contenttype", verbose_name="关联对象类型")),
                ("creator", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="created_missions", to="basic_info.employee", verbose_name="任务创建者")),
            ],
            options={
                "verbose_name": "任务",
                "verbose_name_plural": "任务",
            },
        ),
        migrations.CreateModel(
            name="MissionParticipant",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                ("employee", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="mission_participations", to="basic_info.employee", verbose_name="参与者")),
                ("mission", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="participants", to="mission.mission", verbose_name="任务")),
            ],
            options={
                "verbose_name": "任务参与者",
                "verbose_name_plural": "任务参与者",
            },
        ),
        migrations.CreateModel(
            name="MissionReply",
            fields=[
                ("created_at", models.DateTimeField(auto_now_add=True, verbose_name="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="更新时间")),
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                ("content", models.TextField(verbose_name="回应内容")),
                ("replied_at", models.DateTimeField(db_index=True, default=django.utils.timezone.now, verbose_name="回应时间")),
                ("ends_task", models.BooleanField(db_index=True, default=False, verbose_name="是否结束任务")),
                ("is_rejected", models.BooleanField(db_index=True, default=False, verbose_name="是否被撤销")),
                ("rejected_at", models.DateTimeField(blank=True, null=True, verbose_name="撤销时间")),
                ("mission", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="replies", to="mission.mission", verbose_name="任务")),
                ("responder", models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name="mission_replies", to="basic_info.employee", verbose_name="回应者")),
            ],
            options={
                "verbose_name": "任务回应",
                "verbose_name_plural": "任务回应",
                "ordering": ["replied_at", "id"],
            },
        ),
        migrations.AddIndex(
            model_name="mission",
            index=models.Index(fields=["content_type", "content_id"], name="mission_mis_content_be6081_idx"),
        ),
        migrations.AddIndex(
            model_name="mission",
            index=models.Index(fields=["is_completed", "is_cancelled"], name="mission_mis_is_comp_299039_idx"),
        ),
        migrations.AddConstraint(
            model_name="missionparticipant",
            constraint=models.UniqueConstraint(fields=("mission", "employee"), name="unique_mission_participant"),
        ),
    ]
