# Generated by Django 5.1.7 on 2025-03-25 10:32

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CommunicationEvents',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=250)),
                ('code', models.CharField(max_length=250, unique=True)),
                ('description', models.TextField(max_length=500)),
            ],
            options={
                'verbose_name': 'Communication Event',
                'verbose_name_plural': 'Communication Events',
                'db_table': 'communication_events',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='CommunicationEventsConfigurations',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('communication_type', models.CharField(choices=[('email', 'EMAIL')], max_length=50)),
                ('allowed', models.BooleanField(default=True)),
                ('default_value', models.BooleanField(default=False)),
                ('can_user_change_preference', models.BooleanField(default=True)),
                ('communication_event', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='configurations', to='communication.communicationevents')),
            ],
            options={
                'verbose_name': 'Communication Event Configuration',
                'verbose_name_plural': 'Communication Event Configurations',
                'db_table': 'communication_events_configurations',
                'unique_together': {('communication_event', 'communication_type')},
            },
        ),
        migrations.CreateModel(
            name='CommunicationRequest',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('task_id', models.UUIDField(default=uuid.uuid4, editable=False)),
                ('communication_type', models.CharField(choices=[('email', 'EMAIL')], default='email', max_length=255)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('STARTED', 'Started'), ('SUCCESS', 'Success'), ('RETRYING', 'Retrying'), ('FAILED', 'Failed')], default='PENDING', max_length=55)),
                ('recipients', models.CharField(max_length=255)),
                ('data', models.TextField()),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('next_attempt_time', models.DateTimeField(null=True)),
                ('result', models.TextField(blank=True, null=True)),
                ('traceback', models.TextField(blank=True, null=True)),
                ('retries', models.IntegerField(default=0)),
                ('retries_reasons', models.TextField(default=list)),
                ('communication_event', models.ForeignKey(db_index=False, on_delete=django.db.models.deletion.DO_NOTHING, to='communication.communicationevents')),
                ('user', models.ForeignKey(blank=True, db_index=False, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Communication Request',
                'verbose_name_plural': 'Communication Requests',
                'db_table': 'communication_requests',
                'ordering': ('-created_at',),
                'indexes': [models.Index(fields=['created_at', 'user'], name='communicati_created_1c8644_idx')],
            },
        ),
    ]
