# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2018-06-28 04:20
from __future__ import unicode_literals

import pytz

from django.db import migrations, models
from django.db import transaction


def datetime_to_filename_data_migration(apps, schema_editor):
    FileLog = apps.get_model('nurture', 'FileLog')

    with transaction.atomic():
        for fl in FileLog.objects.all():
            tmp_datetime = fl.uploaded_time.astimezone(pytz.timezone('America/Los_Angeles'))
            fl.filename = tmp_datetime.strftime('%Y%m%d-%H%M%S.txt')
            fl.save()

class Migration(migrations.Migration):

    dependencies = [
        ('nurture', '0002_auto_20180624_1526'),
    ]

    operations = [
        migrations.AddField(
            model_name='filelog',
            name='filename',
            field=models.CharField(default='', max_length=25),
            preserve_default=False,
        ),
        migrations.RunPython(datetime_to_filename_data_migration),
        migrations.RemoveField(
            model_name='filelog',
            name='uploaded_time',
        ),
    ]
