# Generated by Django 3.2.16 on 2023-01-23 20:36

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


class Migration(migrations.Migration):

    dependencies = [
        ("NEMO_billing", "0003_version_2_0_0"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("cap_discount", "0001_initial"),
    ]

    operations = [
        migrations.AddField(
            model_name="capdiscountconfiguration",
            name="split_by_user",
            field=models.BooleanField(
                default=True,
                help_text="Check this box to have a separate CAP amount per each user/account. If unchecked, the CAP will be per account only (all user charges count towards the same CAP)",
            ),
        ),
        migrations.AlterField(
            model_name="capdiscount",
            name="user",
            field=models.ForeignKey(
                blank=True,
                help_text="The user this CAP applies to",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AlterUniqueTogether(
            name="capdiscount",
            unique_together=set(),
        ),
        migrations.AddConstraint(
            model_name="capdiscount",
            constraint=models.UniqueConstraint(
                fields=("configuration", "account", "user"), name="cap_discount_capdiscount_unique_config_account_user"
            ),
        ),
        migrations.AddConstraint(
            model_name="capdiscount",
            constraint=models.UniqueConstraint(
                condition=models.Q(("user", None)),
                fields=("configuration", "account"),
                name="cap_discount_capdiscount_unique_config_account_null_user",
            ),
        ),
    ]
