# Generated by Django 5.1.8 on 2025-08-04 08:49

from django.db import migrations


def add_body_selector(apps, schema_editor):
    DocumentStyle = apps.get_model("style", "DocumentStyle")
    for style in DocumentStyle.objects.all():
        style.contents = style.contents.replace(
            "\r\ndiv#print,\r\ndiv#flow {\r\n    counter-reset",
            "\r\ndiv#print,\r\ndiv#flow,\r\nbody {\r\n    counter-reset",
        )
        style.save()


def remove_body_selector(apps, schema_editor):
    DocumentStyle = apps.get_model("style", "DocumentStyle")
    for style in DocumentStyle.objects.all():
        style.contents = style.contents.replace(
            "\r\ndiv#print,\r\ndiv#flow,\r\nbody {\r\n    counter-reset",
            "\r\ndiv#print,\r\ndiv#flow {\r\n    counter-reset",
        )
        style.save()


class Migration(migrations.Migration):

    dependencies = [
        ("style", "0002_document_styles"),
    ]

    operations = [
        migrations.RunPython(
            add_body_selector,
            remove_body_selector,
        ),
    ]
