# Generated by Django 5.0.9 on 2024-10-11 08:34

from django.db import migrations, models


class Migration(migrations.Migration):
    dependencies = [
        ("currency", "0001_initial"),
        ("geography", "0001_initial"),
        ("io", "0007_alter_exportsource_query_params"),
        ("tags", "0001_initial"),
        ("wbfdm", "0026_instrument_is_cash_equivalent"),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_ric",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_rmc",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_isin",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_sedol",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_valoren",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_cusip",
        ),
        migrations.RemoveConstraint(
            model_name="instrument",
            name="unique_instrument_primary",
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("refinitiv_identifier_code",),
                name="unique_ric",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("refinitiv_mnemonic_code",),
                name="unique_rmc",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("isin",),
                name="unique_isin",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("sedol",),
                name="unique_sedol",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("valoren",),
                name="unique_valoren",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_security", True), ("delisted_date__isnull", True)),
                fields=("cusip",),
                name="unique_cusip",
            ),
        ),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(
                condition=models.Q(("is_primary", True), ("is_managed", False)),
                fields=("parent", "is_primary"),
                name="unique_instrument_primary",
            ),
        ),
    ]
