# Generated by Django 4.2.7 on 2023-11-27 09:12

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


def missing_operations():
    if apps.is_installed("wbportfolio"):
        return [
            migrations.AddField(
                model_name="instrument",
                name="source",
                field=models.CharField(blank=True, max_length=64, null=True),
            ),
            migrations.AddField(
                model_name="instrument",
                name="source_id",
                field=models.CharField(blank=True, max_length=64, null=True),
            ),
            migrations.AddField(
                model_name="exchange",
                name="source",
                field=models.CharField(blank=True, max_length=64, null=True),
            ),
            migrations.AddField(
                model_name="exchange",
                name="source_id",
                field=models.CharField(blank=True, max_length=64, null=True),
            ),
        ]
    return []


class Migration(migrations.Migration):
    dependencies = (
        [
            ("wbfdm", "0010_classification_classificationgroup_deal_exchange_and_more"),
            ("wbportfolio", "0052_remove_cash_instrument_ptr_and_more"),
        ]
        if apps.is_installed("wbportfolio")
        else [
            ("wbfdm", "0010_classification_classificationgroup_deal_exchange_and_more"),
        ]
    )

    operations = [
        migrations.AddField(
            model_name="instrument",
            name="corporate_actions",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="dividends",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="adjustments",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="officers",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="esg",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="esg_controversies",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="financials",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="level",
            field=models.PositiveIntegerField(default=0, editable=False),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="instrument",
            name="lft",
            field=models.PositiveIntegerField(default=0, editable=False),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="instrument",
            name="market_data",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="parent",
            field=mptt.fields.TreeForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="children",
                to="wbfdm.instrument",
                verbose_name="Parent Instrument",
            ),
        ),
        migrations.AddField(
            model_name="instrument",
            name="rght",
            field=models.PositiveIntegerField(default=0, editable=False),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name="instrument",
            name="statements",
            field=models.JSONField(default=dict),
        ),
        migrations.AddField(
            model_name="instrument",
            name="tree_id",
            field=models.PositiveIntegerField(db_index=True, default=0, editable=False),
            preserve_default=False,
        ),
        migrations.AlterField(
            model_name="instrument",
            name="description",
            field=models.TextField(blank=True, default=""),
        ),
        migrations.AlterField(
            model_name="instrument",
            name="instrument_type",
            field=models.CharField(
                blank=True,
                choices=[
                    ("ADR", "American Depository Receipt (ADR)"),
                    ("CF", "Close Ended Fund"),
                    ("EQ", "Equity"),
                    ("ETF", "Exchange Traded Fund"),
                    ("ETC", "Exchange Traded Commodity"),
                    ("ETN", "Exchange Traded Note"),
                    ("WARRANT", "Warrant"),
                    ("GDR", "Global Depository Receipt (GDR)"),
                    ("GS", "Genussschein"),
                    ("TRUST", "Investment Trust"),
                    ("NVDR", "Non-voting depository receipt (NVDR)"),
                    ("PREF", "Preference Share"),
                    ("COMP", "Company"),
                    ("QT", "Quote"),
                    ("Product", "Product"),
                    ("Index", "Index"),
                    ("ProductGroup", "Product Group"),
                    ("Cash", "Cash"),
                ],
                max_length=32,
                null=True,
            ),
        ),
        *missing_operations(),
        migrations.AddConstraint(
            model_name="instrument",
            constraint=models.UniqueConstraint(fields=("source_id", "source"), name="unique_source"),
        ),
    ]
