# Generated by Django 2.2.11 on 2022-05-20 14:11

from django.db import migrations, transaction


def update_json_field_names(apps, schema_editor):
    Asset = apps.get_model("facility", "Asset")

    with transaction.atomic():
        for asset in Asset.objects.all():
            meta = asset.meta
            camera_address = meta.pop("camera_address", None)
            if camera_address:
                meta["local_ip_address"] = camera_address
            asset.meta = meta
            asset.save()


class Migration(migrations.Migration):
    dependencies = [
        ("facility", "0292_auto_20220430_1748"),
    ]

    operations = [
        migrations.RunPython(update_json_field_names, migrations.RunPython.noop)
    ]
