# Generated by Django 3.0 on 2020-03-14 09:43

from django.db import migrations, models

def forward_migration(apps, schema_editor):
    test_obj_a_class = apps.get_model('test_app', 'TestObjA')
    test_objs = test_obj_a_class.objects.all()
    for obj in test_objs:
        # since obj.name is limited to 2 chars we can use the first char as first_name and last char as last_name
        first_name, last_name = (i for i in obj.name)
        obj.first_name = first_name
        obj.last_name = last_name
        obj.save(update_fields=['first_name', 'last_name'])


def backward_migration(apps, schema_editor):
    # backwards we can drop the two fields easily
    pass

class Migration(migrations.Migration):

    dependencies = [
        ('test_app', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='testobja',
            name='first_name',
            field=models.CharField(max_length=1, null=True),
        ),
        migrations.AddField(
            model_name='testobja',
            name='last_name',
            field=models.CharField(max_length=1, null=True),
        ),
        migrations.RunPython(forward_migration, backward_migration)
    ]

746daa84e206918b0934ad05235021a835cd61ed
<mask token>


class Migration(migrations.Migration):
    dependencies = [('test_app', '0001_initial')]
    operations = [migrations.AddField(model_name='testobja', name=
        'first_name', field=models.CharField(max_length=1, null=True)),
        migrations.AddField(model_name='testobja', name='last_name', field=
        models.CharField(max_length=1, null=True)), migrations.RunPython(
        forward_migration, backward_migration)]

<mask token>


def forward_migration(apps, schema_editor):
    test_obj_a_class = apps.get_model('test_app', 'TestObjA')
    test_objs = test_obj_a_class.objects.all()
    for obj in test_objs:
        first_name, last_name = (i for i in obj.name)
        obj.first_name = first_name
        obj.last_name = last_name
        obj.save(update_fields=['first_name', 'last_name'])


<mask token>


class Migration(migrations.Migration):
    dependencies = [('test_app', '0001_initial')]
    operations = [migrations.AddField(model_name='testobja', name=
        'first_name', field=models.CharField(max_length=1, null=True)),
        migrations.AddField(model_name='testobja', name='last_name', field=
        models.CharField(max_length=1, null=True)), migrations.RunPython(
        forward_migration, backward_migration)]

<mask token>


def forward_migration(apps, schema_editor):
    test_obj_a_class = apps.get_model('test_app', 'TestObjA')
    test_objs = test_obj_a_class.objects.all()
    for obj in test_objs:
        first_name, last_name = (i for i in obj.name)
        obj.first_name = first_name
        obj.last_name = last_name
        obj.save(update_fields=['first_name', 'last_name'])


def backward_migration(apps, schema_editor):
    pass


class Migration(migrations.Migration):
    dependencies = [('test_app', '0001_initial')]
    operations = [migrations.AddField(model_name='testobja', name=
        'first_name', field=models.CharField(max_length=1, null=True)),
        migrations.AddField(model_name='testobja', name='last_name', field=
        models.CharField(max_length=1, null=True)), migrations.RunPython(
        forward_migration, backward_migration)]

from django.db import migrations, models


def forward_migration(apps, schema_editor):
    test_obj_a_class = apps.get_model('test_app', 'TestObjA')
    test_objs = test_obj_a_class.objects.all()
    for obj in test_objs:
        first_name, last_name = (i for i in obj.name)
        obj.first_name = first_name
        obj.last_name = last_name
        obj.save(update_fields=['first_name', 'last_name'])


def backward_migration(apps, schema_editor):
    pass


class Migration(migrations.Migration):
    dependencies = [('test_app', '0001_initial')]
    operations = [migrations.AddField(model_name='testobja', name=
        'first_name', field=models.CharField(max_length=1, null=True)),
        migrations.AddField(model_name='testobja', name='last_name', field=
        models.CharField(max_length=1, null=True)), migrations.RunPython(
        forward_migration, backward_migration)]

# Generated by Django 3.0 on 2020-03-14 09:43

from django.db import migrations, models

def forward_migration(apps, schema_editor):
    test_obj_a_class = apps.get_model('test_app', 'TestObjA')
    test_objs = test_obj_a_class.objects.all()
    for obj in test_objs:
        # since obj.name is limited to 2 chars we can use the first char as first_name and last char as last_name
        first_name, last_name = (i for i in obj.name)
        obj.first_name = first_name
        obj.last_name = last_name
        obj.save(update_fields=['first_name', 'last_name'])


def backward_migration(apps, schema_editor):
    # backwards we can drop the two fields easily
    pass

class Migration(migrations.Migration):

    dependencies = [
        ('test_app', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='testobja',
            name='first_name',
            field=models.CharField(max_length=1, null=True),
        ),
        migrations.AddField(
            model_name='testobja',
            name='last_name',
            field=models.CharField(max_length=1, null=True),
        ),
        migrations.RunPython(forward_migration, backward_migration)
    ]
