# Generated by Django 5.2.12 on 2026-04-05 07:02

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="DataProviderSettingsModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "default_source",
                    models.CharField(
                        choices=[
                            ("akshare", "AKShare（推荐）"),
                            ("tushare", "Tushare Pro"),
                            ("failover", "自动容错（AKShare → Tushare）"),
                        ],
                        default="akshare",
                        help_text="Default data source preference",
                        max_length=20,
                    ),
                ),
                (
                    "enable_failover",
                    models.BooleanField(
                        default=True, help_text="Auto-switch to backup provider when primary fails"
                    ),
                ),
                (
                    "failover_tolerance",
                    models.FloatField(
                        default=0.01, help_text="Cross-provider consistency tolerance (0.01 = 1 %)"
                    ),
                ),
                ("description", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Provider Settings",
                "verbose_name_plural": "Provider Settings",
                "db_table": "data_center_provider_settings",
            },
        ),
        migrations.CreateModel(
            name="ProviderConfigModel",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        help_text="Provider name (unique identifier, e.g. 'tushare_main')",
                        max_length=100,
                        unique=True,
                    ),
                ),
                (
                    "source_type",
                    models.CharField(
                        choices=[
                            ("tushare", "Tushare Pro"),
                            ("akshare", "AKShare"),
                            ("eastmoney", "EastMoney"),
                            ("qmt", "QMT (XtQuant)"),
                            ("fred", "FRED"),
                            ("wind", "Wind"),
                            ("choice", "Choice"),
                        ],
                        help_text="Underlying data source type",
                        max_length=20,
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(default=True, help_text="Whether this provider is enabled"),
                ),
                (
                    "priority",
                    models.IntegerField(
                        default=100, help_text="Dispatch priority — lower value = higher precedence"
                    ),
                ),
                (
                    "api_key",
                    models.CharField(blank=True, help_text="API key / token", max_length=500),
                ),
                (
                    "api_secret",
                    models.CharField(
                        blank=True, help_text="API secret (if required)", max_length=500
                    ),
                ),
                (
                    "http_url",
                    models.URLField(
                        blank=True, help_text="Custom HTTP URL (e.g. Tushare third-party proxy)"
                    ),
                ),
                (
                    "api_endpoint",
                    models.URLField(blank=True, help_text="Override API endpoint URL"),
                ),
                (
                    "extra_config",
                    models.JSONField(
                        blank=True, default=dict, help_text="Provider-specific parameters"
                    ),
                ),
                ("description", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Provider Config",
                "verbose_name_plural": "Provider Configs",
                "db_table": "data_center_provider_config",
                "ordering": ["priority", "name"],
                "indexes": [
                    models.Index(
                        fields=["source_type", "is_active"], name="data_center_source__245a49_idx"
                    ),
                    models.Index(fields=["priority"], name="data_center_priorit_259dca_idx"),
                ],
            },
        ),
    ]
