# Generated by Django 3.2.7 on 2021-09-29 23:34

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("zerver", "0365_alter_user_group_related_fields"),
    ]

    operations = [
        migrations.CreateModel(
            name="GroupGroupMembership",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "subgroup",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="zerver.usergroup",
                    ),
                ),
                (
                    "supergroup",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="zerver.usergroup",
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="usergroup",
            name="direct_subgroups",
            field=models.ManyToManyField(
                related_name="direct_supergroups",
                through="zerver.GroupGroupMembership",
                to="zerver.UserGroup",
            ),
        ),
        migrations.AddConstraint(
            model_name="groupgroupmembership",
            constraint=models.UniqueConstraint(
                fields=("supergroup", "subgroup"), name="zerver_groupgroupmembership_uniq"
            ),
        ),
    ]
