# -*- coding: utf-8 -*-
# Generated by Django 1.9b1 on 2015-11-16 09:44
from __future__ import unicode_literals

from django.db import migrations, models

def populate_type_field(apps, schema_editor):
    from takeyourmeds.reminders.enums import TypeEnum

    Reminder = apps.get_model('reminders', 'Reminder')

    for x in Reminder.objects.all():
        x.type = TypeEnum.call if x.audio_url else TypeEnum.message
        x.save()

class Migration(migrations.Migration):

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

    operations = [
        migrations.AddField(
            model_name='reminder',
            name='type',
            field=models.IntegerField(choices=[(b'call', 10), (b'message', 20)], default=10),
            preserve_default=False,
        ),
        migrations.RunPython(
            migrations.RunPython.noop,
            populate_type_field,
        ),
    ]

Move to a type field
Move to a type field
