# Generated by Django 5.2.10 on 2026-02-03 12:20

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


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="CooldownPeriodModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "cooldown_id",
                    models.CharField(
                        db_index=True, help_text="冷却期唯一标识符", max_length=64, unique=True
                    ),
                ),
                (
                    "asset_code",
                    models.CharField(db_index=True, help_text="资产代码", max_length=32),
                ),
                (
                    "last_decision_at",
                    models.DateTimeField(blank=True, help_text="最后决策时间", null=True),
                ),
                (
                    "last_execution_at",
                    models.DateTimeField(blank=True, help_text="最后执行时间", null=True),
                ),
                (
                    "min_decision_interval_hours",
                    models.IntegerField(default=24, help_text="最小决策间隔（小时）"),
                ),
                (
                    "min_execution_interval_hours",
                    models.IntegerField(default=48, help_text="最小执行间隔（小时）"),
                ),
                (
                    "same_asset_cooldown_hours",
                    models.IntegerField(default=72, help_text="同资产冷却期（小时）"),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, help_text="创建时间")),
            ],
            options={
                "verbose_name": "冷却期",
                "verbose_name_plural": "冷却期",
                "db_table": "cooldown_period",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(fields=["asset_code"], name="cooldown_pe_asset_c_047c44_idx")
                ],
            },
        ),
        migrations.CreateModel(
            name="DecisionQuotaModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "quota_id",
                    models.CharField(
                        db_index=True, help_text="配额唯一标识符", max_length=64, unique=True
                    ),
                ),
                (
                    "period",
                    models.CharField(
                        choices=[("daily", "每日"), ("weekly", "每周"), ("monthly", "每月")],
                        db_index=True,
                        help_text="配额周期",
                        max_length=16,
                    ),
                ),
                ("max_decisions", models.IntegerField(default=10, help_text="最大决策次数")),
                ("max_execution_count", models.IntegerField(default=5, help_text="最大执行次数")),
                ("used_decisions", models.IntegerField(default=0, help_text="已使用决策次数")),
                ("used_executions", models.IntegerField(default=0, help_text="已使用执行次数")),
                (
                    "period_start",
                    models.DateTimeField(blank=True, help_text="周期开始时间", null=True),
                ),
                (
                    "period_end",
                    models.DateTimeField(
                        blank=True, db_index=True, help_text="周期结束时间", null=True
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, help_text="创建时间")),
                ("updated_at", models.DateTimeField(auto_now=True, help_text="更新时间")),
            ],
            options={
                "verbose_name": "决策配额",
                "verbose_name_plural": "决策配额",
                "db_table": "decision_quota",
                "ordering": ["period"],
                "indexes": [
                    models.Index(fields=["period"], name="decision_qu_period_730e18_idx"),
                    models.Index(fields=["period_end"], name="decision_qu_period__2cc1ac_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="DecisionRequestModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "request_id",
                    models.CharField(
                        db_index=True, help_text="请求唯一标识符", max_length=64, unique=True
                    ),
                ),
                (
                    "asset_code",
                    models.CharField(db_index=True, help_text="资产代码", max_length=32),
                ),
                ("asset_class", models.CharField(help_text="资产类别", max_length=64)),
                ("direction", models.CharField(help_text="方向", max_length=8)),
                (
                    "priority",
                    models.CharField(
                        choices=[
                            ("critical", "紧急"),
                            ("high", "高"),
                            ("medium", "中"),
                            ("low", "低"),
                            ("info", "信息"),
                        ],
                        default="medium",
                        help_text="优先级",
                        max_length=16,
                    ),
                ),
                (
                    "trigger_id",
                    models.CharField(
                        blank=True, db_index=True, help_text="触发器 ID", max_length=64
                    ),
                ),
                ("reason", models.TextField(blank=True, help_text="原因")),
                ("expected_confidence", models.FloatField(default=0.0, help_text="预期置信度")),
                ("quantity", models.IntegerField(blank=True, help_text="数量", null=True)),
                ("notional", models.FloatField(blank=True, help_text="名义金额", null=True)),
                (
                    "requested_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, help_text="请求时间"),
                ),
                ("expires_at", models.DateTimeField(blank=True, help_text="过期时间", null=True)),
            ],
            options={
                "verbose_name": "决策请求",
                "verbose_name_plural": "决策请求",
                "db_table": "decision_request",
                "ordering": ["-requested_at"],
                "indexes": [
                    models.Index(
                        fields=["asset_code", "-requested_at"],
                        name="decision_re_asset_c_61360e_idx",
                    ),
                    models.Index(
                        fields=["priority", "-requested_at"], name="decision_re_priorit_c14de2_idx"
                    ),
                    models.Index(fields=["trigger_id"], name="decision_re_trigger_e0d30f_idx"),
                ],
            },
        ),
        migrations.CreateModel(
            name="DecisionResponseModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "response_id",
                    models.CharField(
                        db_index=True, help_text="响应唯一标识符", max_length=64, unique=True
                    ),
                ),
                (
                    "approved",
                    models.BooleanField(db_index=True, default=False, help_text="是否批准"),
                ),
                ("approval_reason", models.TextField(blank=True, help_text="批准原因")),
                ("scheduled_at", models.DateTimeField(blank=True, help_text="调度时间", null=True)),
                (
                    "estimated_execution_at",
                    models.DateTimeField(blank=True, help_text="预计执行时间", null=True),
                ),
                ("rejection_reason", models.TextField(blank=True, help_text="拒绝原因")),
                ("wait_until", models.DateTimeField(blank=True, help_text="等待直到", null=True)),
                ("quota_status", models.JSONField(blank=True, help_text="配额状态", null=True)),
                ("cooldown_status", models.TextField(blank=True, help_text="冷却状态")),
                (
                    "alternative_suggestions",
                    models.JSONField(blank=True, help_text="替代建议", null=True),
                ),
                ("responded_at", models.DateTimeField(auto_now_add=True, help_text="响应时间")),
                (
                    "request",
                    models.OneToOneField(
                        help_text="关联的决策请求",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="response",
                        to="decision_rhythm.decisionrequestmodel",
                    ),
                ),
            ],
            options={
                "verbose_name": "决策响应",
                "verbose_name_plural": "决策响应",
                "db_table": "decision_response",
                "ordering": ["-responded_at"],
                "indexes": [
                    models.Index(
                        fields=["approved", "-responded_at"], name="decision_re_approve_592f12_idx"
                    )
                ],
            },
        ),
    ]
