# Generated by Django 3.2.12 on 2022-02-10 10:05
import json
from django.db import migrations

try:
    from rr.utils import fix_json
except ImportError:  # pragma: no cover - legacy compatibility for old installs
    from roadrunner.utils import fix_json


def forward(apps, schema_editor):
    PageMakerBlogPage = apps.get_model("ocyan_plugin_wagtail_blog", "PageMakerBlogPage")
    for row in PageMakerBlogPage.objects.all():
        try:
            data = list(row.content.raw_data)
            fixed_data = fix_json(data)
            row.content = json.dumps(fixed_data)
            row.save()
        except TypeError:
            pass


class Migration(migrations.Migration):

    dependencies = [
        ('ocyan_plugin_wagtail_blog', '0004_pagemakerblogpage'),
    ]

    operations = [
        migrations.RunPython(forward, migrations.RunPython.noop),
    ]
