# Generated by Django 5.1.2 on 2025-05-14 07:52

import custom_base_django.models.choices
import custom_base_django.utils
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        ('custom_base_django', '0003_alter_runperiodictasks_status'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterField(
            model_name='runperiodictasks',
            name='status',
            field=custom_base_django.models.choices.ChoiceForeignKey(blank=True, default=custom_base_django.utils.Defaults.object, limit_choices_to=models.Q(('title', 'task_status')), null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='task_status', to='custom_base_django.choice', verbose_name='task_status'),
        ),
        migrations.CreateModel(
            name='Workflow',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True, verbose_name='is_active')),
                ('is_deleted', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('name', models.CharField(max_length=100, verbose_name='workflow_name')),
                ('description', models.TextField(blank=True, null=True, verbose_name='description')),
                ('content_type_wf', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='related model')),
                ('transition_status', models.ForeignKey(limit_choices_to=models.Q(('choice_title', 'transition_status')), on_delete=django.db.models.deletion.CASCADE, to='custom_base_django.choices', verbose_name='transition status')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WorkflowState',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True, verbose_name='is_active')),
                ('is_deleted', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('name', models.CharField(max_length=100, verbose_name='WorkflowState_name')),
                ('description', models.TextField(blank=True, null=True, verbose_name='description')),
                ('form_struct', models.JSONField(default=list, verbose_name='form_struct')),
                ('extra_data', models.JSONField(blank=True, default=dict, null=True, verbose_name='extra_data')),
                ('order_number', models.IntegerField(default=0, verbose_name='order_number')),
                ('get_single_form', models.BooleanField(default=False, verbose_name='get_single_form')),
                ('can_transition_to', models.ManyToManyField(blank=True, to='custom_base_django.workflowstate', verbose_name='can_transition_to')),
                ('next_state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='self_next_state', to='custom_base_django.workflowstate', verbose_name='next_state')),
                ('previous_state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='self_previous_state', to='custom_base_django.workflowstate', verbose_name='previous_state')),
                ('workflow', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='workflow', to='custom_base_django.workflow')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='WorkflowHistory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_active', models.BooleanField(default=True, verbose_name='is_active')),
                ('is_deleted', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('updated_at', models.DateTimeField(auto_now=True, null=True)),
                ('object_id', models.PositiveIntegerField()),
                ('action_type', models.CharField(blank=True, choices=[('update', 'Update'), ('create', 'Create')], default='update', max_length=100, verbose_name='action_type')),
                ('additional_data', models.JSONField(blank=True, default=dict, verbose_name='additional data')),
                ('description', models.CharField(blank=True, max_length=255, null=True, verbose_name='description')),
                ('deadline', models.DateTimeField(blank=True, null=True, verbose_name='deadline')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='contenttypes.contenttype')),
                ('to_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='assigned_histories', to=settings.AUTH_USER_MODEL, verbose_name='assign to user')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_histories', to=settings.AUTH_USER_MODEL, verbose_name='creator user')),
                ('workflow', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, related_name='workflow_histories', to='custom_base_django.workflow')),
                ('last_state', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='state_histories', to='custom_base_django.workflowstate')),
            ],
            options={
                'abstract': False,
            },
        ),
    ]
