# Generated by Codex on 2026-06-03

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("decision_rhythm", "0013_decisionexecutionlinkmodel"),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name="decisionexecutionlinkmodel",
            name="uq_decision_exec_link_tx_recommendation",
        ),
        migrations.AddField(
            model_name="decisionexecutionlinkmodel",
            name="transaction_source",
            field=models.CharField(
                choices=[
                    ("account_transaction", "账户成交"),
                    ("simulated_trade", "模拟盘成交"),
                ],
                db_index=True,
                default="account_transaction",
                help_text="成交来源：account.TransactionModel 或 simulated_trading.SimulatedTradeModel",
                max_length=32,
            ),
        ),
        migrations.AddIndex(
            model_name="decisionexecutionlinkmodel",
            index=models.Index(
                fields=["transaction_source", "-created_at"],
                name="idx_exec_link_src_time",
            ),
        ),
        migrations.AddConstraint(
            model_name="decisionexecutionlinkmodel",
            constraint=models.UniqueConstraint(
                fields=("transaction_source", "transaction_id", "recommendation_id"),
                name="uq_decision_exec_link_tx_recommendation",
            ),
        ),
    ]
