from __future__ import unicode_literals
from __future__ import absolute_import

from django.db import migrations
from corehq.sql_db.operations import HqRunPython


def noop(*args, **kwargs):
    pass


def _convert_emailed_to_array_field(apps, schema_editor):
    BillingRecord = apps.get_model('accounting', 'BillingRecord')
    for record in BillingRecord.objects.all():
        if record.emailed_to != '':
            record.emailed_to_list = record.emailed_to.split(',')

    WireBillingRecord = apps.get_model('accounting', 'WireBillingRecord')
    for wirerecord in WireBillingRecord.objects.all():
        if wirerecord.emailed_to != '':
            wirerecord.emailed_to_list = wirerecord.emailed_to.split(',')


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0025_auto_20180508_1952'),
    ]

    operations = [
        HqRunPython(_convert_emailed_to_array_field, reverse_code=noop)
    ]

from __future__ import unicode_literals
from __future__ import absolute_import

from django.db import migrations
from corehq.sql_db.operations import HqRunPython


def noop(*args, **kwargs):
    pass


def _convert_emailed_to_array_field(apps, schema_editor):
    BillingRecord = apps.get_model('accounting', 'BillingRecord')
    for record in BillingRecord.objects.all():
        if record.emailed_to != '':
            record.emailed_to_list = record.emailed_to.split(',')
            record.save()

    WireBillingRecord = apps.get_model('accounting', 'WireBillingRecord')
    for wirerecord in WireBillingRecord.objects.all():
        if wirerecord.emailed_to != '':
            wirerecord.emailed_to_list = wirerecord.emailed_to.split(',')
            wirerecord.save()


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0025_auto_20180508_1952'),
    ]

    operations = [
        HqRunPython(_convert_emailed_to_array_field, reverse_code=noop)
    ]

Save record in migrations file
Save record in migrations file

  from __future__ import unicode_literals
  from __future__ import absolute_import
  
  from django.db import migrations
  from corehq.sql_db.operations import HqRunPython
  
  
  def noop(*args, **kwargs):
      pass
  
  
  def _convert_emailed_to_array_field(apps, schema_editor):
      BillingRecord = apps.get_model('accounting', 'BillingRecord')
      for record in BillingRecord.objects.all():
          if record.emailed_to != '':
              record.emailed_to_list = record.emailed_to.split(',')
+             record.save()
  
      WireBillingRecord = apps.get_model('accounting', 'WireBillingRecord')
      for wirerecord in WireBillingRecord.objects.all():
          if wirerecord.emailed_to != '':
              wirerecord.emailed_to_list = wirerecord.emailed_to.split(',')
+             wirerecord.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('accounting', '0025_auto_20180508_1952'),
      ]
  
      operations = [
          HqRunPython(_convert_emailed_to_array_field, reverse_code=noop)
      ]
  
Save record in migrations file
## Code Before:
from __future__ import unicode_literals
from __future__ import absolute_import

from django.db import migrations
from corehq.sql_db.operations import HqRunPython


def noop(*args, **kwargs):
    pass


def _convert_emailed_to_array_field(apps, schema_editor):
    BillingRecord = apps.get_model('accounting', 'BillingRecord')
    for record in BillingRecord.objects.all():
        if record.emailed_to != '':
            record.emailed_to_list = record.emailed_to.split(',')

    WireBillingRecord = apps.get_model('accounting', 'WireBillingRecord')
    for wirerecord in WireBillingRecord.objects.all():
        if wirerecord.emailed_to != '':
            wirerecord.emailed_to_list = wirerecord.emailed_to.split(',')


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0025_auto_20180508_1952'),
    ]

    operations = [
        HqRunPython(_convert_emailed_to_array_field, reverse_code=noop)
    ]

## Instruction:
Save record in migrations file
## Code After:
from __future__ import unicode_literals
from __future__ import absolute_import

from django.db import migrations
from corehq.sql_db.operations import HqRunPython


def noop(*args, **kwargs):
    pass


def _convert_emailed_to_array_field(apps, schema_editor):
    BillingRecord = apps.get_model('accounting', 'BillingRecord')
    for record in BillingRecord.objects.all():
        if record.emailed_to != '':
            record.emailed_to_list = record.emailed_to.split(',')
            record.save()

    WireBillingRecord = apps.get_model('accounting', 'WireBillingRecord')
    for wirerecord in WireBillingRecord.objects.all():
        if wirerecord.emailed_to != '':
            wirerecord.emailed_to_list = wirerecord.emailed_to.split(',')
            wirerecord.save()


class Migration(migrations.Migration):

    dependencies = [
        ('accounting', '0025_auto_20180508_1952'),
    ]

    operations = [
        HqRunPython(_convert_emailed_to_array_field, reverse_code=noop)
    ]
