# Generated by Django 4.2.20 on 2025-05-04 21:51

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


def create_update_status(apps, schema_editor):
    OwnerUpdateStatus = apps.get_model("taxsystem", "OwnerUpdateStatus")
    OwnerAudit = apps.get_model("taxsystem", "OwnerAudit")

    for corporation in OwnerAudit.objects.all():
        sections = [
            "wallet",
            "division",
            "members",
            "payments",
            "payment_system",
            "payday",
        ]
        for section in sections:
            update_status = OwnerUpdateStatus.objects.get_or_create(
                owner=corporation,
                section=section,
            )[0]
            update_status.is_success = None
            update_status.error_message = ""
            update_status.has_token_error = False
            update_status.last_run_at = None
            update_status.last_run_finished_at = None
            update_status.save()


class Migration(migrations.Migration):

    dependencies = [
        (
            "taxsystem",
            "0005_rename_division_corporationwalletdivision_division_id_and_more",
        ),
    ]

    operations = [
        migrations.RunPython(create_update_status),
    ]
