# -*- coding: utf-8 -*-
# Generated by Django 1.9.11 on 2017-04-03 02:14
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    dependencies = [
        ('iati', '0009_auto_20170330_1133'),
    ]

    operations = [
        migrations.AddField(
            model_name='documentlink',
            name='iso_date',
            field=models.DateField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='documentlink',
            name='document_category',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to='iati.DocumentCategory'),
        ),

        migrations.AddField(
            model_name='documentlink',
            name='categories',
            field=models.ManyToManyField(to='iati.DocumentCategory'),
        ),
        migrations.RunSQL([('''
          INSERT INTO iati_documentlink_categories(documentlink_id, documentcategory_id)
          SELECT id, document_category_id FROM iati_documentlink
          WHERE document_category_id IS NOT NULL;''')]
                          ),

        migrations.RemoveField(
            model_name='documentlink',
            name='document_category',
        ),

        migrations.AddField(
            model_name='documentlink',
            name='language',
            field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.CASCADE, to='iati.Language'),
        ),
    ]
