# Generated by Django 4.2.28 on 2026-02-27 07:21

# Django
import django.core.validators
import django.db.models.deletion
from django.db import migrations, models

# Functions from the following migrations need manual copying.
# Move them and any dependencies into this file, then update the
# RunPython operations to refer to the local versions:
# ledger.migrations.0010_fetch_planets_and_update_planetdetails


def _clean_orphan_character_audits_before_character_fk_restore(apps, schema_editor):
    """Remove orphan CharacterOwner rows before re-adding FK in reverse migration."""
    CharacterOwner = apps.get_model("ledger", "CharacterOwner")
    EveCharacter = apps.get_model("eveonline", "EveCharacter")

    eve_character_field = (
        "eve_character_id"
        if any(f.name == "eve_character" for f in CharacterOwner._meta.fields)
        else "character_id"
    )

    valid_character_ids = EveCharacter.objects.using(
        schema_editor.connection.alias
    ).values("id")
    CharacterOwner.objects.using(schema_editor.connection.alias).exclude(
        **{f"{eve_character_field}__in": valid_character_ids}
    ).delete()


class Migration(migrations.Migration):

    replaces = [
        ("ledger", "0001_initial"),
        ("ledger", "0002_delete_corpsteuer_alter_characteraudit_options_and_more"),
        ("ledger", "0003_alter_characteraudit_options_and_more"),
        (
            "ledger",
            "0004_characteraudit_last_update_planetary_characterplanet_and_more",
        ),
        ("ledger", "0005_alter_corporationaudit_options_alter_general_options"),
        ("ledger", "0006_characteraudit_character_name_and_more"),
        ("ledger", "0007_characterplanetdetails_facilitys"),
        ("ledger", "0008_alter_characterminingledger_date"),
        ("ledger", "0009_remove_characteraudit_last_update_mining_and_more"),
        ("ledger", "0010_fetch_planets_and_update_planetdetails"),
        ("ledger", "0011_create_update_status_existings"),
        ("ledger", "0012_alter_corporationwalletjournalentry_division"),
        ("ledger", "0013_delete_events"),
        (
            "ledger",
            "0014_alter_corporationaudit_options_alter_general_options_and_more",
        ),
        ("ledger", "0015_rename_character_characteraudit_eve_character"),
        ("ledger", "0016_characterminingledger_price_per_unit"),
        ("ledger", "0017_alter_eveentity_category_alter_eveentity_eve_id_and_more"),
        (
            "ledger",
            "0018_remove_characterplanet_ledger_char_planet__58a5b6_idx_and_more",
        ),
        ("ledger", "0019_rename_characteraudit_characterowner_and_more"),
        ("ledger", "0020_alter_characterminingledger_system_and_more"),
        ("ledger", "0021_evemarketprice"),
    ]

    initial = True

    dependencies = [
        ("eve_sde", "0012_alter_constellation_region"),
        ("eveonline", "0017_alliance_and_corp_names_are_not_unique"),
    ]

    operations = [
        migrations.CreateModel(
            name="General",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
            ],
            options={
                "permissions": (
                    ("basic_access", "Can access this app, Ledger."),
                    ("admin_access", "Has access to all Administration tools"),
                ),
                "managed": False,
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CharacterOwner",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                ("active", models.BooleanField(default=False)),
                (
                    "last_update_wallet",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                (
                    "last_update_mining",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                (
                    "balance",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                (
                    "character",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_characterowner",
                        to="eveonline.evecharacter",
                    ),
                ),
                (
                    "last_update_planetary",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
            ],
            options={
                "permissions": (
                    ("char_audit_manager", "Has access to all characters for own Corp"),
                    ("char_audit_admin_manager", "Has access to all characters"),
                ),
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CorporationOwner",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "last_update_wallet",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                (
                    "corporation",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_corporationowner",
                        to="eveonline.evecorporationinfo",
                    ),
                ),
            ],
            options={
                "permissions": (
                    ("corp_audit_manager", "Has access to own Corporation"),
                    ("corp_audit_admin_manager", "Has access to all Corporations"),
                ),
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CorporationWalletDivision",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(default=None, max_length=100, null=True)),
                ("balance", models.DecimalField(decimal_places=2, max_digits=20)),
                ("division", models.IntegerField()),
                (
                    "corporation",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_corporation_division",
                        to="ledger.corporationowner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="Events",
            fields=[
                ("id", models.BigAutoField(primary_key=True, serialize=False)),
                ("title", models.CharField(max_length=100, null=True)),
                ("date_start", models.DateTimeField(blank=True, null=True)),
                ("date_end", models.DateTimeField(blank=True, null=True)),
                ("description", models.TextField(blank=True, null=True)),
                ("char_ledger", models.BooleanField(default=False, null=True)),
                ("location", models.CharField(blank=True, max_length=100, null=True)),
            ],
            options={
                "verbose_name": "event",
                "verbose_name_plural": "events",
                "permissions": (("event_admin_access", "Can access Events Tools"),),
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="EveEntity",
            fields=[
                (
                    "eve_id",
                    models.IntegerField(
                        primary_key=True,
                        serialize=False,
                        validators=[django.core.validators.MinValueValidator(0)],
                        verbose_name="id",
                    ),
                ),
                (
                    "category",
                    models.CharField(
                        choices=[
                            ("alliance", "Alliance"),
                            ("corporation", "Corporation"),
                            ("character", "Character"),
                        ],
                        max_length=32,
                        verbose_name="category",
                    ),
                ),
                ("name", models.CharField(max_length=254, verbose_name="name")),
                ("last_update", models.DateTimeField(auto_now=True)),
                (
                    "alliance",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="alli",
                        to="ledger.eveentity",
                    ),
                ),
                (
                    "corporation",
                    models.ForeignKey(
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="corp",
                        to="ledger.eveentity",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CharacterMiningLedger",
            fields=[
                (
                    "id",
                    models.CharField(max_length=50, primary_key=True, serialize=False),
                ),
                ("date", models.DateField()),
                ("quantity", models.IntegerField()),
                (
                    "character",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_character",
                        to="ledger.characterowner",
                    ),
                ),
                (
                    "system",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_evesolarsystem",
                        to="eve_sde.solarsystem",
                    ),
                ),
                (
                    "type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_evetype",
                        to="eve_sde.itemtype",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CorporationWalletJournalEntry",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                (
                    "balance",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                ("context_id", models.BigIntegerField(default=None, null=True)),
                (
                    "context_id_type",
                    models.CharField(
                        choices=[
                            ("structure_id", "Structure Id"),
                            ("station_id", "Station Id"),
                            ("market_transaction_id", "Market Transaction Id"),
                            ("character_id", "Character Id"),
                            ("corporation_id", "Corporation Id"),
                            ("alliance_id", "Alliance Id"),
                            ("eve_system", "Eve System"),
                            ("industry_job_id", "Industry Job Id"),
                            ("contract_id", "Contract Id"),
                            ("planet_id", "Planet Id"),
                            ("system_id", "System Id"),
                            ("type_id", "Type Id"),
                        ],
                        default=None,
                        max_length=30,
                        null=True,
                    ),
                ),
                ("date", models.DateTimeField()),
                ("description", models.CharField(max_length=500)),
                ("entry_id", models.BigIntegerField()),
                ("reason", models.CharField(default=None, max_length=500, null=True)),
                ("ref_type", models.CharField(max_length=72)),
                (
                    "tax",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                ("tax_receiver_id", models.IntegerField(default=None, null=True)),
                (
                    "division",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="ledger.corporationwalletdivision",
                    ),
                ),
                (
                    "first_party",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        related_name="+",
                        to="ledger.eveentity",
                    ),
                ),
                (
                    "second_party",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        related_name="+",
                        to="ledger.eveentity",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_permissions": (),
                "indexes": [
                    models.Index(fields=["date"], name="ledger_corp_date_c08a55_idx"),
                    models.Index(
                        fields=["amount"], name="ledger_corp_amount_e482ac_idx"
                    ),
                    models.Index(
                        fields=["entry_id"], name="ledger_corp_entry_i_e36818_idx"
                    ),
                    models.Index(
                        fields=["ref_type"], name="ledger_corp_ref_typ_280f5b_idx"
                    ),
                    models.Index(
                        fields=["first_party"], name="ledger_corp_first_p_114662_idx"
                    ),
                    models.Index(
                        fields=["second_party"], name="ledger_corp_second__9a820c_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="CharacterWalletJournalEntry",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                (
                    "balance",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                ("context_id", models.BigIntegerField(default=None, null=True)),
                (
                    "context_id_type",
                    models.CharField(
                        choices=[
                            ("structure_id", "Structure Id"),
                            ("station_id", "Station Id"),
                            ("market_transaction_id", "Market Transaction Id"),
                            ("character_id", "Character Id"),
                            ("corporation_id", "Corporation Id"),
                            ("alliance_id", "Alliance Id"),
                            ("eve_system", "Eve System"),
                            ("industry_job_id", "Industry Job Id"),
                            ("contract_id", "Contract Id"),
                            ("planet_id", "Planet Id"),
                            ("system_id", "System Id"),
                            ("type_id", "Type Id"),
                        ],
                        default=None,
                        max_length=30,
                        null=True,
                    ),
                ),
                ("date", models.DateTimeField()),
                ("description", models.CharField(max_length=500)),
                ("entry_id", models.BigIntegerField()),
                ("reason", models.CharField(default=None, max_length=500, null=True)),
                ("ref_type", models.CharField(max_length=72)),
                (
                    "tax",
                    models.DecimalField(
                        decimal_places=2, default=None, max_digits=20, null=True
                    ),
                ),
                ("tax_receiver_id", models.IntegerField(default=None, null=True)),
                (
                    "character",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="ledger.characterowner",
                    ),
                ),
                (
                    "first_party",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        related_name="+",
                        to="ledger.eveentity",
                    ),
                ),
                (
                    "second_party",
                    models.ForeignKey(
                        blank=True,
                        default=None,
                        null=True,
                        on_delete=django.db.models.deletion.SET_DEFAULT,
                        related_name="+",
                        to="ledger.eveentity",
                    ),
                ),
            ],
            options={
                "abstract": False,
                "default_permissions": (),
                "indexes": [
                    models.Index(fields=["date"], name="ledger_char_date_e50f13_idx"),
                    models.Index(
                        fields=["amount"], name="ledger_char_amount_2c2575_idx"
                    ),
                    models.Index(
                        fields=["entry_id"], name="ledger_char_entry_i_8f5952_idx"
                    ),
                    models.Index(
                        fields=["ref_type"], name="ledger_char_ref_typ_f611b2_idx"
                    ),
                    models.Index(
                        fields=["first_party"], name="ledger_char_first_p_c0bd40_idx"
                    ),
                    models.Index(
                        fields=["second_party"], name="ledger_char_second__aa3ded_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="CharacterPlanet",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "upgrade_level",
                    models.IntegerField(
                        default=0, help_text="Upgrade level of the planet"
                    ),
                ),
                (
                    "num_pins",
                    models.IntegerField(
                        default=0, help_text="Number of pins on the planet"
                    ),
                ),
                (
                    "last_update",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                (
                    "character",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_characterplanet",
                        to="ledger.characterowner",
                    ),
                ),
                (
                    "planet",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_planet",
                        to="eve_sde.planet",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.CreateModel(
            name="CharacterPlanetDetails",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                ("links", models.JSONField(blank=True, default=None, null=True)),
                ("pins", models.JSONField(blank=True, default=None, null=True)),
                ("routes", models.JSONField(blank=True, default=None, null=True)),
                (
                    "last_update",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                (
                    "last_alert",
                    models.DateTimeField(blank=True, default=None, null=True),
                ),
                ("notification", models.BooleanField(default=False)),
                ("notification_sent", models.BooleanField(default=False)),
                (
                    "planet",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_characterplanetdetails",
                        to="ledger.characterplanet",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "indexes": [
                    models.Index(
                        fields=["planet"], name="ledger_char_planet__6169b9_idx"
                    )
                ],
            },
        ),
        migrations.AddIndex(
            model_name="characterplanet",
            index=models.Index(
                fields=["character"], name="ledger_char_charact_f3af73_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="characterplanet",
            index=models.Index(
                fields=["planet"], name="ledger_char_planet__58a5b6_idx"
            ),
        ),
        migrations.AlterModelOptions(
            name="corporationowner",
            options={
                "default_permissions": (),
                "permissions": (
                    ("corp_audit_admin_manager", "Has access to all Corporations"),
                ),
            },
        ),
        migrations.AlterModelOptions(
            name="general",
            options={
                "default_permissions": (),
                "managed": False,
                "permissions": (
                    ("basic_access", "Can access this app, Ledger."),
                    ("advanced_access", "Can access Corporation and Alliance Ledger."),
                    ("admin_access", "Has access to all Administration tools"),
                ),
            },
        ),
        migrations.AddField(
            model_name="characterowner",
            name="character_name",
            field=models.CharField(default=None, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name="characterplanet",
            name="planet_name",
            field=models.CharField(default=None, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name="corporationowner",
            name="corporation_name",
            field=models.CharField(default=None, max_length=100, null=True),
        ),
        migrations.AddField(
            model_name="characterplanetdetails",
            name="facilitys",
            field=models.JSONField(blank=True, default=None, null=True),
        ),
        migrations.AlterField(
            model_name="characterminingledger",
            name="date",
            field=models.DateTimeField(),
        ),
        migrations.RemoveField(
            model_name="characterowner",
            name="last_update_mining",
        ),
        migrations.RemoveField(
            model_name="characterowner",
            name="last_update_planetary",
        ),
        migrations.RemoveField(
            model_name="characterowner",
            name="last_update_wallet",
        ),
        migrations.RemoveField(
            model_name="characterplanet",
            name="last_update",
        ),
        migrations.RemoveField(
            model_name="characterplanetdetails",
            name="last_update",
        ),
        migrations.AddField(
            model_name="characterplanetdetails",
            name="character",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_character_planet_details",
                to="ledger.characterowner",
            ),
        ),
        migrations.AlterField(
            model_name="characterowner",
            name="active",
            field=models.BooleanField(default=True),
        ),
        migrations.AlterField(
            model_name="characterminingledger",
            name="character",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_character_mining",
                to="ledger.characterowner",
            ),
        ),
        migrations.AlterField(
            model_name="characterplanet",
            name="character",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_character_planet",
                to="ledger.characterowner",
            ),
        ),
        migrations.AlterField(
            model_name="characterplanetdetails",
            name="planet",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_planet_details",
                to="ledger.characterplanet",
            ),
        ),
        migrations.AlterField(
            model_name="characterwalletjournalentry",
            name="character",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_character_journal",
                to="ledger.characterowner",
            ),
        ),
        migrations.CreateModel(
            name="CharacterUpdateStatus",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "section",
                    models.CharField(
                        choices=[
                            ("wallet_journal", "Wallet Journal"),
                            ("mining_ledger", "Mining Ledger"),
                            ("planets", "Planets"),
                            ("planets_details", "Planets Details"),
                        ],
                        db_index=True,
                        max_length=32,
                    ),
                ),
                (
                    "is_success",
                    models.BooleanField(db_index=True, default=None, null=True),
                ),
                ("error_message", models.TextField()),
                ("has_token_error", models.BooleanField(default=False)),
                (
                    "last_run_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_run_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "character",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_update_status",
                        to="ledger.characterowner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.RenameField(
            model_name="corporationwalletdivision",
            old_name="division",
            new_name="division_id",
        ),
        migrations.RemoveField(
            model_name="corporationowner",
            name="last_update_wallet",
        ),
        migrations.AddField(
            model_name="corporationowner",
            name="active",
            field=models.BooleanField(default=True),
        ),
        migrations.CreateModel(
            name="CorporationUpdateStatus",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "section",
                    models.CharField(
                        choices=[
                            ("wallet_division", "Divisions"),
                            ("wallet_journal", "Wallet Journal"),
                        ],
                        db_index=True,
                        max_length=32,
                    ),
                ),
                (
                    "is_success",
                    models.BooleanField(db_index=True, default=None, null=True),
                ),
                ("error_message", models.TextField()),
                ("has_token_error", models.BooleanField(default=False)),
                (
                    "last_run_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_run_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last run has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been started at this time",
                        null=True,
                    ),
                ),
                (
                    "last_update_finished_at",
                    models.DateTimeField(
                        db_index=True,
                        default=None,
                        help_text="Last update has been successful finished at this time",
                        null=True,
                    ),
                ),
                (
                    "corporation",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="ledger_corporation_update_status",
                        to="ledger.corporationowner",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
        migrations.AlterField(
            model_name="characterplanetdetails",
            name="character",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_character_planet_details",
                to="ledger.characterowner",
            ),
        ),
        migrations.AlterField(
            model_name="corporationwalletjournalentry",
            name="division",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="ledger_corporation_journal",
                to="ledger.corporationwalletdivision",
            ),
        ),
        migrations.DeleteModel(
            name="Events",
        ),
        migrations.AlterModelOptions(
            name="corporationowner",
            options={
                "default_permissions": (),
                "permissions": (
                    ("corp_audit_manager", "Has Access to own Corporations."),
                    ("corp_audit_admin_manager", "Has access to all Corporations."),
                ),
            },
        ),
        migrations.AlterModelOptions(
            name="general",
            options={
                "default_permissions": (),
                "managed": False,
                "permissions": (
                    ("basic_access", "Can access this app, Ledger."),
                    ("advanced_access", "Can access Corporation and Alliance Ledger."),
                    ("manage_access", "Can manage Ledger."),
                ),
            },
        ),
        migrations.AlterField(
            model_name="corporationupdatestatus",
            name="section",
            field=models.CharField(
                choices=[
                    ("wallet_division_names", "Divisions Names"),
                    ("wallet_division", "Divisions"),
                    ("wallet_journal", "Wallet Journal"),
                ],
                db_index=True,
                max_length=32,
            ),
        ),
        migrations.RenameField(
            model_name="characterowner",
            old_name="character",
            new_name="eve_character",
        ),
        migrations.RunPython(
            code=migrations.RunPython.noop,
            reverse_code=_clean_orphan_character_audits_before_character_fk_restore,
        ),
        migrations.AddField(
            model_name="characterminingledger",
            name="price_per_unit",
            field=models.DecimalField(
                decimal_places=2, default=None, max_digits=20, null=True
            ),
        ),
        migrations.AlterField(
            model_name="eveentity",
            name="category",
            field=models.CharField(
                choices=[
                    ("alliance", "Alliance"),
                    ("corporation", "Corporation"),
                    ("character", "Character"),
                ],
                max_length=32,
                verbose_name="Category",
            ),
        ),
        migrations.AlterField(
            model_name="eveentity",
            name="eve_id",
            field=models.IntegerField(
                primary_key=True,
                serialize=False,
                validators=[django.core.validators.MinValueValidator(0)],
                verbose_name="ID",
            ),
        ),
        migrations.AlterField(
            model_name="eveentity",
            name="name",
            field=models.CharField(max_length=254, verbose_name="Name"),
        ),
        migrations.RemoveIndex(
            model_name="characterplanet",
            name="ledger_char_planet__58a5b6_idx",
        ),
        migrations.RenameField(
            model_name="characterplanet",
            old_name="planet",
            new_name="eve_planet",
        ),
        migrations.RenameField(
            model_name="characterplanet",
            old_name="planet_name",
            new_name="name",
        ),
        migrations.RenameField(
            model_name="corporationowner",
            old_name="corporation",
            new_name="eve_corporation",
        ),
        migrations.AddIndex(
            model_name="characterplanet",
            index=models.Index(
                fields=["eve_planet"], name="ledger_char_eve_pla_d4379e_idx"
            ),
        ),
        migrations.RenameField(
            model_name="characterplanetdetails",
            old_name="facilitys",
            new_name="factories",
        ),
        migrations.RenameField(
            model_name="characterupdatestatus",
            old_name="character",
            new_name="owner",
        ),
        migrations.RenameField(
            model_name="corporationupdatestatus",
            old_name="corporation",
            new_name="owner",
        ),
        migrations.AddIndex(
            model_name="characterwalletjournalentry",
            index=models.Index(
                fields=["character"], name="ledger_char_charact_fa27b8_idx"
            ),
        ),
        migrations.AddIndex(
            model_name="corporationwalletjournalentry",
            index=models.Index(
                fields=["division"], name="ledger_corp_divisio_6ef4ce_idx"
            ),
        ),
        migrations.CreateModel(
            name="EveMarketPrice",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("adjusted_price", models.FloatField(default=None, null=True)),
                ("average_price", models.FloatField(default=None, null=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "eve_type",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="eve_sde.itemtype",
                    ),
                ),
            ],
            options={
                "default_permissions": (),
            },
        ),
    ]
