# Generated by Django 4.2.17 on 2025-01-04 16:42

from django.db import migrations
from django.db.migrations.state import StateApps
from django.db.models import F


def invert_is_manually_manageable(apps: StateApps, schema_editor):
    """Invert `is_manually_manageable`.

    This field is a renaming of `is_meta`.
    However, the meaning has been inverted : the groups
    which were meta are not manually manageable and vice versa.
    Thus, the value must be inverted.
    """
    Group = apps.get_model("core", "Group")
    Group.objects.all().update(is_manually_manageable=~F("is_manually_manageable"))


class Migration(migrations.Migration):
    dependencies = [("core", "0041_delete_metagroup_alter_group_options_and_more")]

    operations = [
        migrations.RunPython(
            invert_is_manually_manageable, reverse_code=invert_is_manually_manageable
        ),
    ]
