# Generated by Django 5.2.9 on 2026-01-02 01:11

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("macro", "0006_macroindicator_unit"),
    ]

    operations = [
        migrations.AddField(
            model_name="macroindicator",
            name="original_unit",
            field=models.CharField(
                default="", help_text="原始单位（数据源返回的单位，用于展示）", max_length=50
            ),
        ),
        migrations.AlterField(
            model_name="macroindicator",
            name="unit",
            field=models.CharField(
                default="", help_text="存储单位（货币类统一为元）", max_length=50
            ),
        ),
        migrations.CreateModel(
            name="IndicatorUnitConfig",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "indicator_code",
                    models.CharField(
                        db_index=True, help_text="指标代码（如 CN_GDP, CN_M2）", max_length=50
                    ),
                ),
                (
                    "source",
                    models.CharField(
                        choices=[
                            ("akshare", "AKShare"),
                            ("tushare", "Tushare Pro"),
                            ("fred", "FRED"),
                            ("wind", "Wind"),
                            ("manual", "手动配置"),
                        ],
                        default="manual",
                        help_text="数据源",
                        max_length=20,
                    ),
                ),
                (
                    "original_unit",
                    models.CharField(
                        help_text="原始单位（如 亿元、万亿元、万元等）", max_length=50
                    ),
                ),
                (
                    "is_currency",
                    models.BooleanField(
                        default=False, help_text="是否为货币类指标（货币类会转换为元存储）"
                    ),
                ),
                (
                    "priority",
                    models.IntegerField(
                        default=0, help_text="优先级（数字越大越优先，用于多数据源冲突时）"
                    ),
                ),
                ("description", models.CharField(blank=True, help_text="单位说明", max_length=200)),
                ("is_active", models.BooleanField(default=True, help_text="是否启用")),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "指标单位配置",
                "verbose_name_plural": "指标单位配置",
                "db_table": "indicator_unit_config",
                "ordering": ["-priority", "indicator_code"],
                "unique_together": {("indicator_code", "source")},
            },
        ),
    ]
