# Generated by Django 3.1.7 on 2021-03-26 21:53

from django.db import migrations
import django_jsonfield_backport.models


def convert_strings_to_lists(apps, schema_editor):
    Notification = apps.get_model('notifications', 'Notification')
    for notification in Notification.objects.all():
        channels = notification.channels
        if channels:
            notification.channels_json = channels
        else:
            notification.channels = list()

        notification.save()


def reverse_convert_strings_to_lists(apps, schema_editor):
    Notification = apps.get_model('notifications', 'Notification')
    for notification in Notification.objects.all():
        notification.channels_json = list()
        notification.save()


class Migration(migrations.Migration):

    dependencies = [
        ('notifications', '0002_django_jsonfield_backport'),
    ]

    operations = [
        migrations.AddField(
            model_name='notification',
            name='channels_json',
            field=django_jsonfield_backport.models.JSONField(default=list),
        ),

        migrations.RunPython(
            convert_strings_to_lists, reverse_convert_strings_to_lists
        )
    ]
