# Generated by Django 5.2.10 on 2026-02-22 14:11

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("sentiment", "0004_sentimentindex_data_sufficient"),
    ]

    operations = [
        migrations.CreateModel(
            name="SentimentAlertModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "alert_type",
                    models.CharField(
                        choices=[
                            ("ai_failure", "AI 调用失败"),
                            ("no_data", "无数据"),
                            ("data_stale", "数据过期"),
                        ],
                        db_index=True,
                        max_length=50,
                        verbose_name="告警类型",
                    ),
                ),
                (
                    "severity",
                    models.CharField(
                        choices=[
                            ("info", "信息"),
                            ("warning", "警告"),
                            ("error", "错误"),
                            ("critical", "严重"),
                        ],
                        db_index=True,
                        default="warning",
                        max_length=20,
                        verbose_name="严重程度",
                    ),
                ),
                ("title", models.CharField(max_length=255, verbose_name="告警标题")),
                ("message", models.TextField(verbose_name="告警详情")),
                ("metadata", models.JSONField(blank=True, null=True, verbose_name="元数据")),
                (
                    "is_resolved",
                    models.BooleanField(db_index=True, default=False, verbose_name="是否已解决"),
                ),
                (
                    "resolved_at",
                    models.DateTimeField(blank=True, null=True, verbose_name="解决时间"),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, verbose_name="创建时间"),
                ),
            ],
            options={
                "verbose_name": "Sentiment 告警",
                "verbose_name_plural": "Sentiment 告警",
                "db_table": "sentiment_alert",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(
                        fields=["alert_type", "is_resolved"], name="sentiment_a_alert_t_e026c7_idx"
                    ),
                    models.Index(
                        fields=["severity", "is_resolved"], name="sentiment_a_severit_99a577_idx"
                    ),
                ],
            },
        ),
    ]
