# Generated by Django 3.2.16 on 2023-02-09 16:20

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

import nautobot.core.celery
import nautobot.extras.utils


class Migration(migrations.Migration):
    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("extras", "0067_migrate_job_result_status"),
    ]

    operations = [
        migrations.RemoveIndex(
            model_name="jobresult",
            name="extras_jobresult_rcreated_idx",
        ),
        migrations.RemoveIndex(
            model_name="jobresult",
            name="extras_jr_rcompleted_idx",
        ),
        migrations.RemoveIndex(
            model_name="jobresult",
            name="extras_jr_statrcreate_idx",
        ),
        migrations.RemoveIndex(
            model_name="jobresult",
            name="extras_jr_statrcompl_idx",
        ),
        migrations.AlterModelOptions(
            name="jobresult",
            options={"get_latest_by": "date_created", "ordering": ["-date_created"]},
        ),
        migrations.RenameField(
            model_name="jobresult",
            old_name="created",
            new_name="date_created",
        ),
        migrations.RenameField(
            model_name="jobresult",
            old_name="completed",
            new_name="date_done",
        ),
        migrations.RenameField(
            model_name="jobresult",
            old_name="job_kwargs",
            new_name="task_args",
        ),
        migrations.RenameField(
            model_name="jobresult",
            old_name="job_id",
            new_name="task_id",
        ),
        migrations.AddField(
            model_name="jobresult",
            name="meta",
            field=models.JSONField(default=None, editable=False, null=True),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="periodic_task_name",
            field=models.CharField(max_length=255, null=True),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="result",
            field=models.TextField(default=None, editable=False, null=True),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="task_kwargs",
            field=models.JSONField(
                blank=True, default=dict, encoder=nautobot.core.celery.encoders.NautobotKombuJSONEncoder
            ),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="task_name",
            field=models.CharField(db_index=True, max_length=255, null=True),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="traceback",
            field=models.TextField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="jobresult",
            name="worker",
            field=models.CharField(default=None, max_length=100, null=True),
        ),
        migrations.AlterField(
            model_name="jobresult",
            name="obj_type",
            field=models.ForeignKey(
                blank=True,
                limit_choices_to=nautobot.extras.utils.FeatureQuery("job_results"),
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="job_results",
                to="contenttypes.contenttype",
            ),
        ),
        migrations.AlterField(
            model_name="jobresult",
            name="status",
            field=models.CharField(db_index=True, default="PENDING", max_length=30),
        ),
        migrations.AddIndex(
            model_name="jobresult",
            index=models.Index(fields=["-date_created"], name="extras_jobresult_rcreated_idx"),
        ),
        migrations.AddIndex(
            model_name="jobresult",
            index=models.Index(fields=["-date_done"], name="extras_jr_rdone_idx"),
        ),
        migrations.AddIndex(
            model_name="jobresult",
            index=models.Index(fields=["status", "-date_created"], name="extras_jr_statrcreate_idx"),
        ),
        migrations.AddIndex(
            model_name="jobresult",
            index=models.Index(fields=["status", "-date_done"], name="extras_jr_statrdone_idx"),
        ),
    ]
