# Generated by Django 5.2.15 on 2026-06-15 08:51

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('billing', '0001_initial'),
        ('clients', '0001_initial'),
        ('services', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='HistoricalInternalTask',
            fields=[
                ('id', models.BigIntegerField(auto_created=True, blank=True, db_index=True, verbose_name='ID')),
                ('public_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False)),
                ('created_at', models.DateTimeField(blank=True, editable=False, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(blank=True, editable=False, verbose_name='Atualizado em')),
                ('title', models.CharField(max_length=180, verbose_name='Título')),
                ('task_type', models.CharField(choices=[('renew_service', 'Renovar serviço'), ('confirm_payment', 'Confirmar pagamento'), ('contact_client', 'Contactar cliente'), ('update_dns', 'Atualizar DNS'), ('verify_ssl', 'Verificar SSL'), ('create_backup', 'Criar backup'), ('technical_check', 'Verificação técnica'), ('other', 'Outro')], default='other', max_length=30, verbose_name='Tipo')),
                ('priority', models.CharField(choices=[('low', 'Baixa'), ('normal', 'Normal'), ('high', 'Alta'), ('urgent', 'Urgente')], db_index=True, default='normal', max_length=15, verbose_name='Prioridade')),
                ('status', models.CharField(choices=[('todo', 'Por fazer'), ('in_progress', 'Em curso'), ('waiting', 'A aguardar'), ('done', 'Concluída'), ('cancelled', 'Cancelada')], db_index=True, default='todo', max_length=20, verbose_name='Estado')),
                ('due_date', models.DateField(blank=True, db_index=True, null=True, verbose_name='Data limite')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Concluída em')),
                ('description', models.TextField(blank=True, verbose_name='Descrição')),
                ('history_id', models.AutoField(primary_key=True, serialize=False)),
                ('history_date', models.DateTimeField(db_index=True)),
                ('history_change_reason', models.CharField(max_length=100, null=True)),
                ('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
                ('assigned_to', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to=settings.AUTH_USER_MODEL, verbose_name='Responsável')),
                ('client', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='clients.client', verbose_name='Cliente')),
                ('history_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('renewal', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='billing.renewal', verbose_name='Renovação')),
                ('service', models.ForeignKey(blank=True, db_constraint=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='+', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'historical Tarefa interna',
                'verbose_name_plural': 'historical Tarefas internas',
                'ordering': ('-history_date', '-history_id'),
                'get_latest_by': ('history_date', 'history_id'),
            },
            bases=(simple_history.models.HistoricalChanges, models.Model),
        ),
        migrations.CreateModel(
            name='InternalTask',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('public_id', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Criado em')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Atualizado em')),
                ('title', models.CharField(max_length=180, verbose_name='Título')),
                ('task_type', models.CharField(choices=[('renew_service', 'Renovar serviço'), ('confirm_payment', 'Confirmar pagamento'), ('contact_client', 'Contactar cliente'), ('update_dns', 'Atualizar DNS'), ('verify_ssl', 'Verificar SSL'), ('create_backup', 'Criar backup'), ('technical_check', 'Verificação técnica'), ('other', 'Outro')], default='other', max_length=30, verbose_name='Tipo')),
                ('priority', models.CharField(choices=[('low', 'Baixa'), ('normal', 'Normal'), ('high', 'Alta'), ('urgent', 'Urgente')], db_index=True, default='normal', max_length=15, verbose_name='Prioridade')),
                ('status', models.CharField(choices=[('todo', 'Por fazer'), ('in_progress', 'Em curso'), ('waiting', 'A aguardar'), ('done', 'Concluída'), ('cancelled', 'Cancelada')], db_index=True, default='todo', max_length=20, verbose_name='Estado')),
                ('due_date', models.DateField(blank=True, db_index=True, null=True, verbose_name='Data limite')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Concluída em')),
                ('description', models.TextField(blank=True, verbose_name='Descrição')),
                ('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_internal_tasks', to=settings.AUTH_USER_MODEL, verbose_name='Responsável')),
                ('client', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='internal_tasks', to='clients.client', verbose_name='Cliente')),
                ('renewal', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='internal_tasks', to='billing.renewal', verbose_name='Renovação')),
                ('service', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='internal_tasks', to='services.service', verbose_name='Serviço')),
            ],
            options={
                'verbose_name': 'Tarefa interna',
                'verbose_name_plural': 'Tarefas internas',
                'ordering': ['status', 'due_date', '-priority', 'title'],
                'indexes': [models.Index(fields=['status', 'due_date'], name='operations__status_e071bc_idx'), models.Index(fields=['assigned_to', 'status'], name='operations__assigne_f21b67_idx')],
            },
        ),
    ]
