# Generated by Django 2.2.10 on 2021-03-19 14:37 from django.db import migrations, models from django.db.models import F def forward(apps, schema_editor): """Move `text` field to `hardcoded_field`.""" models = [ 'OrganisationQuestion', 'OrganisationRelationshipQuestion', 'PersonQuestion', 'RelationshipQuestion', ] models = map(lambda m: apps.get_model('people', m), models) for model in models: model.objects.filter(is_hardcoded=True).update( hardcoded_field=F('text')) def backward(apps, schema_editor): """Move `hardcoded_field` to `text` field.""" models = [ 'OrganisationQuestion', 'OrganisationRelationshipQuestion', 'PersonQuestion', 'RelationshipQuestion', ] models = map(lambda m: apps.get_model('people', m), models) for model in models: model.objects.exclude(hardcoded_field='').update( text=F('hardcoded_field'), is_hardcoded=True) class Migration(migrations.Migration): dependencies = [ ('people', '0050_relationship_remove_timestamps'), ] operations = [ migrations.AddField( model_name='organisationquestion', name='hardcoded_field', field=models.CharField(blank=True, help_text='Which hardcoded field does this question represent?', max_length=255), ), migrations.AddField( model_name='organisationrelationshipquestion', name='hardcoded_field', field=models.CharField(blank=True, help_text='Which hardcoded field does this question represent?', max_length=255), ), migrations.AddField( model_name='personquestion', name='hardcoded_field', field=models.CharField(blank=True, help_text='Which hardcoded field does this question represent?', max_length=255), ), migrations.AddField( model_name='relationshipquestion', name='hardcoded_field', field=models.CharField(blank=True, help_text='Which hardcoded field does this question represent?', max_length=255), ), migrations.RunPython(forward, backward), migrations.RemoveField( model_name='organisationquestion', name='is_hardcoded', ), migrations.RemoveField( model_name='organisationrelationshipquestion', name='is_hardcoded', ), migrations.RemoveField( model_name='personquestion', name='is_hardcoded', ), migrations.RemoveField( model_name='relationshipquestion', name='is_hardcoded', ), ]