# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-14 01:43
from __future__ import unicode_literals

from django.db import migrations


MAPPING = [
    ('promgen.sender.email', 'promgen.notification.email'),
    ('promgen.sender.ikasan', 'promgen.notification.ikasan'),
    ('promgen.sender.linenotify', 'promgen.notification.linenotify'),
    ('promgen.sender.webhook', 'promgen.notification.webhook'),
]


def convert_to_notification(apps, schema_editor):
    Sender = apps.get_model('promgen', 'Sender')
    for _from, _to in MAPPING:
        Sender.objects.filter(sender=_from).update(sender=_to)


def convert_to_sender(apps, schema_editor):
    Sender = apps.get_model('promgen', 'Sender')
    for _to, _from in MAPPING:
        Sender.objects.filter(sender=_from).update(sender=_to)


class Migration(migrations.Migration):

    dependencies = [
        ('promgen', '0030_exporter_enabled'),
    ]

    operations = [
        migrations.RunPython(convert_to_notification, convert_to_sender),
    ]
