# Generated by Django 2.2.2 on 2019-06-21 20:12

from django.db import migrations


def move_keys(apps, schema_editor):
    AssignedContent = apps.get_model("spider_base", "AssignedContent")
    AnchorKey = apps.get_model("spider_keys", "AnchorKey")

    for i in AssignedContent.objects.filter(
        ctype__name="AnchorKey"
    ):
        content = AnchorKey.objects.get(id=i.object_id)
        i.attached_to_content = content.key
        i.save(update_fields=["attached_to_content"])


class Migration(migrations.Migration):

    dependencies = [
        ('spider_keys', '0002_20190426_squashed'),
    ]

    operations = [
        migrations.RunPython(move_keys),
    ]
