# Generated by Django 2.2.7 on 2020-01-27 20:04

from django.db import migrations, models
import utils.models


def clear_data(apps, schema_editor):
    City = apps.get_model('location', 'City')
    for city in City.objects.all():
        city.name = None
        city.save()


def preserve_field_data(apps, schema_editor):
    City = apps.get_model('location', 'City')
    for city in City.objects.all():
        city.name = city.name_translated
        city.save()


class Migration(migrations.Migration):

    dependencies = [
        ('location', '0035_auto_20200115_1117'),
    ]


    operations = [
        migrations.AlterField(
            model_name='city',
            name='name',
            field=models.CharField(max_length=250, null=True, verbose_name='name'),
        ),
        migrations.RunPython(clear_data, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='city',
            name='name',
            field=utils.models.TJSONField(default=None, help_text='{"en-GB":"some city name"}', null=True, verbose_name='City name json'),
        ),
        migrations.RunPython(preserve_field_data, migrations.RunPython.noop),
        migrations.RemoveField(
            model_name='city',
            name='name_translated',
        )
    ]
