# Generated by Django 2.2.2 on 2019-06-26 16:20

from django.db import migrations


def forward_filter_rename(apps, schema_editor):
    AuthToken = apps.get_model("spider_base", "AuthToken")

    for i in AuthToken.objects.all():
        i.extra["search"] = i.extra.pop("filter", None) or []
        i.extra["request_search"] = i.extra.pop("request_filter", None)
        i.save(update_fields=["extra"])


def backward_filter_rename(apps, schema_editor):
    AuthToken = apps.get_model("spider_base", "AuthToken")

    for i in AuthToken.objects.all():
        i.extra["filter"] = i.extra.pop("search", None) or []
        i.extra["request_filter"] = i.extra.pop("request_search", None)
        i.save(update_fields=["extra"])


class Migration(migrations.Migration):

    dependencies = [
        ('spider_base', '0004_auto_20190621_2126'),
    ]

    operations = [
        migrations.RunPython(forward_filter_rename, backward_filter_rename),
    ]
