# Generated by Django 6.0.4 on 2026-06-06 02:55

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('events', '0001_initial'),
        ('projects', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Approval',
            fields=[
                ('id', models.UUIDField(default=apps.tasks.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('description', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('pending', 'Pending'), ('approved', 'Approved'), ('rejected', 'Rejected'), ('revised', 'Revised')], default='pending', max_length=20)),
                ('data', models.JSONField(default=dict)),
                ('comment', models.TextField(blank=True)),
                ('resolved_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('approver', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pending_approvals', to=settings.AUTH_USER_MODEL)),
                ('requester', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='approval_requests', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'approvals',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Task',
            fields=[
                ('id', models.UUIDField(default=apps.tasks.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('title', models.CharField(max_length=255)),
                ('description', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('todo', 'To Do'), ('in_progress', 'In Progress'), ('review', 'Review'), ('done', 'Done'), ('cancelled', 'Cancelled'), ('archived', 'Archived')], default='todo', max_length=20)),
                ('priority', models.CharField(choices=[('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('urgent', 'Urgent')], default='medium', max_length=20)),
                ('approved_at', models.DateTimeField(blank=True, null=True)),
                ('archived_at', models.DateTimeField(blank=True, null=True)),
                ('source', models.CharField(blank=True, default='', max_length=20)),
                ('due_date', models.DateTimeField(blank=True, null=True)),
                ('tags', models.JSONField(default=list)),
                ('subtasks', models.JSONField(default=list)),
                ('attachments', models.JSONField(default=list)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('assignee', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_tasks', to=settings.AUTH_USER_MODEL)),
                ('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='created_tasks', to=settings.AUTH_USER_MODEL)),
                ('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='events.event')),
                ('project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tasks', to='projects.project')),
            ],
            options={
                'db_table': 'tasks',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id', models.UUIDField(default=apps.tasks.models.uuid7, editable=False, primary_key=True, serialize=False)),
                ('content', models.TextField()),
                ('attachments', models.JSONField(default=list)),
                ('is_read', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('related_approval', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='tasks.approval')),
                ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='task_messages', to=settings.AUTH_USER_MODEL)),
                ('related_task', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='messages', to='tasks.task')),
            ],
            options={
                'db_table': 'messages',
                'ordering': ['created_at'],
            },
        ),
        migrations.AddIndex(
            model_name='approval',
            index=models.Index(fields=['status'], name='approvals_status_658918_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['status'], name='tasks_status_031d4c_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['priority'], name='tasks_priorit_a9efa1_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['due_date'], name='tasks_due_dat_0359a9_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['project', 'status'], name='tasks_project_fe19a5_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['assignee', 'status'], name='tasks_assigne_972e70_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['approved_at'], name='tasks_approve_4ee046_idx'),
        ),
        migrations.AddIndex(
            model_name='task',
            index=models.Index(fields=['source'], name='tasks_source_5ea740_idx'),
        ),
        migrations.AddIndex(
            model_name='message',
            index=models.Index(fields=['is_read'], name='messages_is_read_6a69c0_idx'),
        ),
        migrations.AddIndex(
            model_name='message',
            index=models.Index(fields=['related_task', 'created_at'], name='messages_related_ac1bac_idx'),
        ),
        migrations.AddIndex(
            model_name='message',
            index=models.Index(fields=['related_approval', 'created_at'], name='messages_related_b1c21b_idx'),
        ),
    ]
