# Generated by Django 2.2.28 on 2022-08-05 15:20

from django.db import migrations, models


def transfer_reindex_tasks(apps, schema_editor):
    # We can't import the Person model directly as it may be a newer
    # version than this migration expects. We use the historical version.

    Reindexer = apps.get_model('elastic', 'Reindexer')
    for orm in Reindexer.objects.filter(task__isnull=False):
        task = getattr(orm, "task", None)
        if task:
            orm.tasks.add(orm.task)



class Migration(migrations.Migration):
    dependencies = [
        ('core', '0022_make_last_update_automatic'),
        ('elastic', '0016_deletefactsbyquerytask_editfactsbyquerytask'),
    ]

    operations = [
        migrations.AddField(
            model_name='reindexer',
            name='tasks',
            field=models.ManyToManyField(to='core.Task'),
        ),
        migrations.AlterField(
            model_name='reindexer',
            name='description',
            field=models.CharField(max_length=1000),
        ),
        migrations.RunPython(transfer_reindex_tasks),

        migrations.RemoveField(
            model_name='reindexer',
            name='task',
        ),

    ]
