# Generated by Django 3.2.20 on 2023-11-22 15:22

from django.db import migrations


def delete_parent_projects(apps, schema):
    """Delete parent projects before deleting the model"""
    ProjectContainer = apps.get_model(
        "meinberlin_projectcontainers", "ProjectContainer"
    )
    Project = apps.get_model("a4projects", "Project")

    for projectcontainer in ProjectContainer.objects.all():
        project = Project.objects.get(pk=projectcontainer.pk)
        assert project.name == projectcontainer.name
        project.delete()


class Migration(migrations.Migration):
    dependencies = [
        ("a4follows", "0002_verbose_name_created_modified"),
        ("meinberlin_offlineevents", "0008_alter_offlineevent_description"),
        ("meinberlin_newsletters", "0008_alter_newsletter_body"),
        ("meinberlin_projects", "0004_verbose_name_created_modified"),
        ("a4modules", "0007_verbose_name_created_modified"),
        ("a4actions", "0008_set_action_obj_comment_creator"),
        ("a4comments", "0013_set_project"),
        ("meinberlin_plans", "0057_alter_plan_description"),
        ("meinberlin_projectcontainers", "0003_custom_project_types"),
    ]

    operations = [
        migrations.RunPython(delete_parent_projects),
    ]
