# Generated by Django 5.1.4 on 2025-01-10 21:11

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('django_goals', '0007_goal_goals_achieved_idx'),
    ]

    operations = [
        migrations.RemoveIndex(
            model_name='goal',
            name='goals_waiting_for_precond_idx',
        ),
        migrations.AddField(
            model_name='goal',
            name='preconditions_mode',
            field=models.CharField(choices=[('all', 'All preconditions must be achieved before the goal can be pursued.'), ('any', 'Goal can be pursued if any of the preconditions is achieved.')], default='all', max_length=3),
        ),
        migrations.AddIndex(
            model_name='goal',
            index=models.Index(models.Q(('waiting_for_count__lte', 0)), condition=models.Q(('state', 'waiting_for_preconditions')), name='goals_waiting_for_precond_idx'),
        ),
        migrations.AddConstraint(
            model_name='goal',
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(('preconditions_mode', 'any'), ('waiting_for_count__lte', 1)),
                    ('preconditions_mode', 'all'),
                    _connector='OR',
                ),
                name='goals_waiting_for_count_any',
            ),
        ),
    ]
