# Generated by Django 5.0.1 on 2024-03-31 13:58

from django.conf import settings
from django.db import migrations


def forwards_func(apps, schema_editor):
    BeaconMeasurement = apps.get_model('mapdata', 'BeaconMeasurement')
    for measurement in BeaconMeasurement.objects.all():
        measurement.data = {"wifi": measurement.data}
        measurement.save()


def backwards_func(apps, schema_editor):
    BeaconMeasurement = apps.get_model('mapdata', 'BeaconMeasurement')
    for measurement in BeaconMeasurement.objects.all():
        measurement.data = measurement.data["wifi"]
        measurement.save()


class Migration(migrations.Migration):

    dependencies = [
        ('mapdata', '0105_alter_theme_color_background_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.RenameModel(
            old_name='WifiMeasurement',
            new_name='BeaconMeasurement',
        ),
        migrations.AlterModelOptions(
            name='beaconmeasurement',
            options={'default_related_name': 'beacon_measurements', 'verbose_name': 'Beacon Measurement',
                     'verbose_name_plural': 'Beacon Measurements'},
        ),
        migrations.RunPython(forwards_func, backwards_func),
    ]
