# Generated by Django 4.1 on 2022-08-25 10:18

from django.db import migrations, models


def reverse_bool(apps, schema_editor):
    model = apps.get_model("portal", "Flatpage")

    for row in model.objects.all():
        row.published = not row.draft
        row.save(update_fields=["published"])


def reverse_bool_back(apps, schema_editor):
    model = apps.get_model("portal", "Flatpage")

    for row in model.objects.all():
        row.draft = not row.published
        row.save(update_fields=["draft"])


class Migration(migrations.Migration):

    dependencies = [
        ("portal", "0012_md_to_html"),
    ]

    operations = [
        migrations.AddField(
            model_name="flatpage",
            name="published",
            field=models.BooleanField(default=False),
        ),
        migrations.RunPython(
            reverse_bool,
            reverse_code=reverse_bool_back
        ),
        migrations.RemoveField(
            model_name="flatpage",
            name="draft",
        ),
    ]
