# Generated by Django 4.2.23 on 2025-12-23 17:08

from django.db import migrations, models

import debusine.tasks.models


class Migration(migrations.Migration):
    dependencies = [
        ('db', '0038_worker_tombstones_without_tokens'),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name='worker',
            name='db_worker_celery_or_token',
        ),
        migrations.AlterField(
            model_name='worker',
            name='worker_type',
            field=models.CharField(
                choices=[
                    (
                        debusine.tasks.models.WorkerType['SCHEDULER'],
                        debusine.tasks.models.WorkerType['SCHEDULER'],
                    ),
                    (
                        debusine.tasks.models.WorkerType['EXTERNAL'],
                        debusine.tasks.models.WorkerType['EXTERNAL'],
                    ),
                    (
                        debusine.tasks.models.WorkerType['CELERY'],
                        debusine.tasks.models.WorkerType['CELERY'],
                    ),
                    (
                        debusine.tasks.models.WorkerType['SIGNING'],
                        debusine.tasks.models.WorkerType['SIGNING'],
                    ),
                ],
                default=debusine.tasks.models.WorkerType['EXTERNAL'],
                editable=False,
            ),
        ),
        migrations.AddConstraint(
            model_name='worker',
            constraint=models.CheckConstraint(
                check=models.Q(
                    (
                        'worker_type__in',
                        {
                            debusine.tasks.models.WorkerType['SCHEDULER'],
                            debusine.tasks.models.WorkerType['CELERY'],
                        },
                    ),
                    ('activation_token__isnull', False),
                    ('token__isnull', False),
                    models.Q(
                        ('instance_created_at__isnull', True),
                        ('worker_pool_id__isnull', False),
                    ),
                    _connector='OR',
                ),
                name='db_worker_celery_or_token',
            ),
        ),
    ]
