# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-10-26 15:59
from __future__ import unicode_literals

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion

def migrate_data(apps, schema_editor):
    Document = apps.get_model('document', 'Document')
    for d in Document.objects.all():
        if 'title' not in d.data:
            d.data['title'] = d.name
        if 'description' not in d.data:
            d.data['description'] = d.description
        d.save()

class Migration(migrations.Migration):

    dependencies = [
        ('document', '0006_auto_20161026_1259'),
    ]

    operations = [
        migrations.RunPython(migrate_data),
        migrations.AlterField(
            model_name='document',
            name='user',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='documents', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AlterUniqueTogether(
            name='document',
            unique_together=set([]),
        ),
        migrations.RemoveField(
            model_name='document',
            name='description_sort',
        ),
        migrations.RemoveField(
            model_name='document',
            name='dimensions_sort',
        ),
        migrations.RemoveField(
            model_name='document',
            name='name_sort',
        ),
        migrations.RemoveField(
            model_name='document',
            name='name',
        ),
        migrations.RemoveField(
            model_name='document',
            name='description',
        ),
    ]
