# Generated by Django 5.2.1 on 2025-05-16 13:47

import aleksis.core.mixins
import ckeditor.fields
import colorfield.fields
import django.contrib.postgres.fields
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


def _migrate(apps, schema):
    TaskUserAssignment = apps.get_model("core", "TaskUserAssignment")
    for assignment in TaskUserAssignment.objects.all():
        assignment.task_id = assignment.task_result.task_id
        assignment.save()

class Migration(migrations.Migration):

    dependencies = [
        ('core', '0088_availabilitytype'),
        ('django_celery_results', '0014_alter_taskresult_status'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='taskuserassignment',
            name='task_id',
            field=models.CharField(blank=True, verbose_name='Task ID'),
        ),
        migrations.RunPython(_migrate),
        migrations.AddConstraint(
            model_name='taskuserassignment',
            constraint=models.UniqueConstraint(condition=models.Q(('task_id', ''), _negated=True), fields=('task_id',), name='unique_task_id'),
        ),
        migrations.RemoveField(
            model_name='taskuserassignment',
            name='task_result',
        ),
    ]
