# Generated by Django 4.2.26 on 2025-12-01 17:38

from django.db import migrations, models
from django.db.migrations.operations.special import RunPython


def set_started_at(apps, schema_editor):
    TaskResult = apps.get_model('django_cron_tasks', 'TaskResult')
    for obj in TaskResult.objects.all():
        obj.started_at = obj.created_at
        obj.save(update_fields=['started_at'])


class Migration(migrations.Migration):

    dependencies = [
        ('django_cron_tasks', '0002_lock'),
    ]

    operations = [
        migrations.RenameField(
            model_name='taskresult',
            old_name='started_at',
            new_name='created_at',
        ),
        migrations.AlterIndexTogether(
            name='taskresult',
            index_together=set(),
        ),
        migrations.AddField(
            model_name='taskresult',
            name='started_by_scheduler',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='taskresult',
            name='args',
            field=models.JSONField(default=None, null=True),
        ),
        migrations.AddField(
            model_name='taskresult',
            name='kwargs',
            field=models.JSONField(default=None, null=True),
        ),
        migrations.AddField(
            model_name='taskresult',
            name='started_at',
            field=models.DateTimeField(default=None, null=True),
        ),
        migrations.AlterField(
            model_name='taskresult',
            name='started_by_scheduler',
            field=models.BooleanField(default=None, null=True),
        ),
        migrations.AlterIndexTogether(
            name='taskresult',
            index_together={('name', 'started_by_scheduler', 'created_at'), ('created_at', 'started_at')},
        ),
        migrations.RunPython(
            set_started_at,
            RunPython.noop,
        ),
    ]
