# Generated by Django 2.2.4 on 2019-10-18 13:47

from django.db import migrations, models


def fill_establishment_subtype(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.
    EstablishmentSubType = apps.get_model('establishment', 'EstablishmentSubType')
    for n, et in enumerate(EstablishmentSubType.objects.all()):
        et.index_name = 'Type %s' % n
        et.save()


class Migration(migrations.Migration):

    dependencies = [
        ('establishment', '0038_establishmenttype_index_name'),
    ]

    operations = [
        migrations.AddField(
            model_name='establishmentsubtype',
            name='index_name',
            field=models.CharField(blank=True, db_index=True, max_length=50, null=True, unique=True, default=None, verbose_name='Index name'),
        ),
        migrations.RunPython(fill_establishment_subtype, migrations.RunPython.noop),
        migrations.AlterField(
            model_name='establishmentsubtype',
            name='index_name',
            field=models.CharField(choices=[('winery', 'Winery'), ], db_index=True, max_length=50,
                                   unique=True, verbose_name='Index name'),
        ),

    ]
