# Generated by Django 2.2.4 on 2019-10-23 11:13

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


def fill_currency_name(apps, schema_editor):
    # We can't import the Person model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Currency = apps.get_model('main', 'Currency')
    for currency in Currency.objects.all():
        currency.name_json = {'en-GB': currency.name}
        currency.save()



class Migration(migrations.Migration):

    dependencies = [
        ('main', '0021_auto_20191023_0924'),
    ]

    operations = [
        migrations.AddField(
            model_name='currency',
            name='sign',
            field=models.CharField(default='?', max_length=1, verbose_name='sign'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='currency',
            name='slug',
            field=models.SlugField(default='?', max_length=255, unique=True),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='sitesettings',
            name='currency',
            field=models.ForeignKey(default=None, null=True, on_delete=django.db.models.deletion.PROTECT, to='main.Currency'),
        ),
        migrations.AddField(
            model_name='currency',
            name='name_json',
            field=utils.models.TJSONField(blank=True, default=None, help_text='{"en-GB":"some text"}', null=True, verbose_name='name'),
        ),
        migrations.RunPython(fill_currency_name, migrations.RunPython.noop),
        migrations.RemoveField(
            model_name='currency',
            name='name',
        ),
        migrations.RenameField(
            model_name='currency',
            old_name='name_json',
            new_name='name',
        ),
    ]
