# Generated by Django 4.2.9 on 2024-01-16 00:05

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


class Migration(migrations.Migration):

    dependencies = [
        ('auth', '0012_alter_user_first_name_max_length'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('django_datawatch', '0003_resultstatushistory'),
    ]

    operations = [
        migrations.CreateModel(
            name='ResultAssignedUser',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('result', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_datawatch.result', verbose_name='Result')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='User')),
            ],
            options={
                'verbose_name': 'Result assigned user',
                'verbose_name_plural': 'Result assigned users',
            },
        ),
        migrations.CreateModel(
            name='ResultAssignedGroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.group', verbose_name='Group')),
                ('result', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='django_datawatch.result', verbose_name='Result')),
            ],
            options={
                'verbose_name': 'Result assigned group',
                'verbose_name_plural': 'Result assigned groups',
            },
        ),
        migrations.AddField(
            model_name='result',
            name='assigned_groups',
            field=models.ManyToManyField(blank=True, related_name='assigned_groups', through='django_datawatch.ResultAssignedGroup', to='auth.group', verbose_name='Assigned groups'),
        ),
        migrations.AddField(
            model_name='result',
            name='assigned_users',
            field=models.ManyToManyField(blank=True, related_name='assigned_results', through='django_datawatch.ResultAssignedUser', to=settings.AUTH_USER_MODEL, verbose_name='Assigned users'),
        ),
        migrations.AddConstraint(
            model_name='resultassigneduser',
            constraint=models.UniqueConstraint(fields=('result', 'user'), name='unique_result_assigned_user'),
        ),
        migrations.AddConstraint(
            model_name='resultassignedgroup',
            constraint=models.UniqueConstraint(fields=('result', 'group'), name='unique_result_assigned_group'),
        ),
    ]
