# Generated by Django 2.1.5 on 2019-01-16 14:26

from django.db import migrations, models
from phone_login.models import PhoneToken, random_string


def create_random_string(apps, schema_editor):
    Device = apps.get_model('phone_login', 'phonetoken')
    for token in PhoneToken.objects.all():
        token.reference_id = random_string()
        print(token.reference_id)
        token.save(update_fields=['reference_id'])


class Migration(migrations.Migration):

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

    operations = [
        migrations.AddField(
            model_name='phonetoken',
            name='reference_id',
            field=models.CharField(default="randomstring", null=True, editable=False, max_length=12),
        ),
        migrations.RunPython(create_random_string),
        migrations.AlterField(
            model_name='phonetoken',
            name='reference_id',
            field=models.CharField(unique=True, null=False, max_length=12, editable=False)
        )
    ]
