# Generated by Django 4.2.1 on 2023-06-21 11:44

from django import VERSION as DJANGO_VERSION
from django.db import migrations, models


check_constraint_condition = models.Q(
    ("permission__isnull", False),
    ("permission_type__isnull", False),
    _connector="OR",
)

check_constraint_kwargs = {"name": "permission_or_permission_type_not_null"}

if DJANGO_VERSION >= (5, 1):
    check_constraint_kwargs["condition"] = check_constraint_condition
else:
    check_constraint_kwargs["check"] = check_constraint_condition


class Migration(migrations.Migration):

    dependencies = [
        ("wagtailcore", "0086_populate_grouppagepermission_permission"),
    ]

    operations = [
        migrations.AlterUniqueTogether(
            name="grouppagepermission",
            unique_together=set(),
        ),
        migrations.AddConstraint(
            model_name="grouppagepermission",
            constraint=models.CheckConstraint(**check_constraint_kwargs),
        ),
        migrations.AddConstraint(
            model_name="grouppagepermission",
            constraint=models.UniqueConstraint(
                fields=("group", "page", "permission"),
                name="unique_permission",
            ),
        ),
        migrations.AddConstraint(
            model_name="grouppagepermission",
            constraint=models.UniqueConstraint(
                fields=("group", "page", "permission_type"),
                name="unique_permission_type",
            ),
        ),
    ]
