# Generated by Django 4.2.13 on 2024-06-18 13:18
from django.db import migrations, models


def copy_progress_data(apps, schema_editor):
    LongRunningJob = apps.get_model("api", "LongRunningJob")
    for job in LongRunningJob.objects.all():
        result = job.result
        job.progress_current = result["progress"]["current"]
        job.progress_target = result["progress"]["target"]
        job.save()


class Migration(migrations.Migration):
    dependencies = [
        ("api", "0067_alter_longrunningjob_job_type"),
    ]

    operations = [
        migrations.AddField(
            model_name="longrunningjob",
            name="progress_current",
            field=models.PositiveIntegerField(default=0),
        ),
        migrations.AddField(
            model_name="longrunningjob",
            name="progress_target",
            field=models.PositiveIntegerField(default=0),
        ),
        migrations.RunPython(copy_progress_data),
        migrations.RemoveField(
            model_name="longrunningjob",
            name="result",
        ),
    ]
