# Generated by Django 5.2.15 on 2026-07-06 12:22

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('customers', '0001_initial'),
        ('tenancy', '0002_auditlog'),
    ]

    operations = [
        migrations.CreateModel(
            name='NotificationJob',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('channel', models.CharField(choices=[('SMS', 'SMS'), ('WHATSAPP', 'WhatsApp')], max_length=20)),
                ('status', models.CharField(choices=[('PENDING', 'Pending'), ('PROCESSING', 'Processing'), ('SENT', 'Sent'), ('FAILED', 'Failed'), ('CANCELLED', 'Cancelled')], default='PENDING', max_length=20)),
                ('event_type', models.CharField(max_length=100)),
                ('recipient', models.CharField(max_length=255)),
                ('subject', models.CharField(blank=True, max_length=255)),
                ('message', models.TextField()),
                ('context', models.JSONField(blank=True, default=dict)),
                ('provider_name', models.CharField(blank=True, max_length=100)),
                ('provider_message_id', models.CharField(blank=True, max_length=255)),
                ('failure_reason', models.TextField(blank=True)),
                ('attempt_count', models.PositiveIntegerField(default=0)),
                ('processing_started_at', models.DateTimeField(blank=True, null=True)),
                ('sent_at', models.DateTimeField(blank=True, null=True)),
                ('failed_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('customer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='notification_jobs', to='customers.customer')),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(app_label)s_%(class)s_records', to='tenancy.organization')),
                ('service_account', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='notification_jobs', to='customers.serviceaccount')),
            ],
            options={
                'db_table': 'notifications_notification_job',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['organization', 'status'], name='notif_job_org_status_idx'), models.Index(fields=['organization', 'channel'], name='notif_job_org_channel_idx'), models.Index(fields=['organization', 'event_type'], name='notif_job_org_event_idx'), models.Index(fields=['organization', 'customer'], name='notif_job_org_customer_idx')],
            },
        ),
    ]
