# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2018-12-20 09:39
from __future__ import unicode_literals

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

def migrate_data(apps, schema_editor):
    Project = apps.get_model('djangoldp_project', 'Project')
    ChatConfig = apps.get_model('djangoldp_account', 'ChatConfig')
    for project in Project.objects.all():
        chat_config = ChatConfig()
        chat_config.jabberID = project.jabberID
        chat_config.jabberRoom = project.jabberRoom
        chat_config.save()
        project.chatConfig = chat_config
        project.save()


class Migration(migrations.Migration):

    dependencies = [
        ('djangoldp_account', '0001_initial'),
        ('djangoldp_project', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='project',
            name='chatConfig',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='projects', to='djangoldp_account.ChatConfig'),
        ),
        migrations.RunPython(migrate_data),
        migrations.RemoveField(
            model_name='project',
            name='jabberID',
        ),
        migrations.RemoveField(
            model_name='project',
            name='jabberRoom',
        ),

    ]
