# Generated by Django 5.2.10 on 2026-03-04 13:40

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("policy", "0007_add_workbench_fields"),
    ]

    operations = [
        migrations.CreateModel(
            name="InAppNotification",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("title", models.CharField(max_length=200, verbose_name="标题")),
                ("content", models.TextField(verbose_name="内容")),
                (
                    "channel",
                    models.CharField(
                        choices=[("email", "邮件"), ("in_app", "站内信"), ("webhook", "Webhook")],
                        default="in_app",
                        max_length=20,
                        verbose_name="通知渠道",
                    ),
                ),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("low", "低"),
                            ("normal", "普通"),
                            ("high", "高"),
                            ("critical", "紧急"),
                        ],
                        db_index=True,
                        default="normal",
                        max_length=20,
                        verbose_name="优先级",
                    ),
                ),
                (
                    "recipient_username",
                    models.CharField(
                        blank=True,
                        help_text="留空表示全局通知",
                        max_length=150,
                        null=True,
                        verbose_name="收件人用户名",
                    ),
                ),
                (
                    "is_global",
                    models.BooleanField(
                        default=False,
                        help_text="是否为全局通知（所有用户可见）",
                        verbose_name="全局通知",
                    ),
                ),
                ("is_read", models.BooleanField(default=False, verbose_name="已读")),
                ("read_at", models.DateTimeField(blank=True, null=True, verbose_name="读取时间")),
                (
                    "metadata",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="额外的结构化信息",
                        verbose_name="元数据",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="创建时间"),
                ),
            ],
            options={
                "verbose_name": "站内通知",
                "verbose_name_plural": "站内通知",
                "db_table": "in_app_notification",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(fields=["-created_at"], name="in_app_noti_created_ee3bc5_idx"),
                    models.Index(
                        fields=["recipient_username", "-created_at"],
                        name="in_app_noti_recipie_45a048_idx",
                    ),
                    models.Index(
                        fields=["is_read", "priority"], name="in_app_noti_is_read_bd9484_idx"
                    ),
                    models.Index(
                        fields=["is_global", "-created_at"], name="in_app_noti_is_glob_8f7fd6_idx"
                    ),
                ],
            },
        ),
    ]
