# Generated by Django 6.0.3 on 2026-03-11 17:11

import django.db.models.deletion
import django_geoaddress.fields
import django_providerkit.fields
import django_pymissive.fields
import django_pymissive.models.attachment
import django_pymissive.models.webhook
import django_pymissive.utils
import phonenumber_field.modelfields
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='MissiveProviderModel',
            fields=[
                ('name', models.CharField(help_text='Provider name (e.g., sendgrid)', max_length=255, primary_key=True, serialize=False, verbose_name='Name')),
                ('display_name', models.CharField(help_text='Provider display name', verbose_name='Display Name')),
                ('description', models.CharField(help_text='Provider description', verbose_name='Description')),
                ('priority', models.IntegerField(help_text='Provider priority', verbose_name='Priority')),
                ('config_status_str', models.CharField(help_text='Config status', verbose_name='Config status')),
                ('config_prefix', models.CharField(help_text='Config prefix', verbose_name='Config prefix')),
                ('config_keys', models.JSONField(help_text='Config keys', verbose_name='Config keys')),
                ('missing_config_keys', models.JSONField(help_text='Missing config keys', verbose_name='Missing config keys')),
                ('is_config_ready', models.BooleanField(help_text='Is config ready', verbose_name='Is config ready')),
                ('package_status_str', models.CharField(help_text='Package status', verbose_name='Package status')),
                ('required_packages', models.JSONField(help_text='Required packages', verbose_name='Required packages')),
                ('missing_packages', models.JSONField(help_text='Missing packages', verbose_name='Missing packages')),
                ('are_packages_installed', models.BooleanField(help_text='Are packages installed', verbose_name='Are packages installed')),
                ('service_status_str', models.CharField(help_text='Service status', verbose_name='Service status')),
                ('missing_services', models.JSONField(help_text='Missing services', verbose_name='Missing services')),
                ('services', models.JSONField(help_text='Services', verbose_name='Services')),
                ('are_services_implemented', models.BooleanField(help_text='Are services implemented', verbose_name='Are services implemented')),
            ],
            options={
                'verbose_name': 'Provider',
                'verbose_name_plural': 'Providers',
                'ordering': ['-priority', 'name'],
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='MissiveServiceModel',
            fields=[
                ('name', models.CharField(help_text='Service name', max_length=255, primary_key=True, serialize=False, verbose_name='Name')),
                ('fields', models.JSONField(help_text='Service fields', verbose_name='Service fields')),
                ('description', models.CharField(help_text='Service description', verbose_name='Service description')),
            ],
            options={
                'verbose_name': 'Provider Service',
                'verbose_name_plural': 'Provider Services',
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='MissiveWebhook',
            fields=[
                ('provider', django_providerkit.fields.ProviderField(blank=True, help_text='Provider used to send this missive', max_length=100, null=True, verbose_name='Provider')),
                ('webhook_id', models.CharField(help_text='Webhook ID', max_length=255, primary_key=True, serialize=False, verbose_name='Webhook ID')),
                ('scheme', models.CharField(blank=True, choices=[('https', 'HTTPS'), ('http', 'HTTP')], default=django_pymissive.models.webhook.get_default_webhook_scheme, help_text='HTTP or HTTPS', max_length=5, verbose_name='Scheme')),
                ('domain', models.CharField(blank=True, default=django_pymissive.utils.get_default_domain, help_text='Base domain (e.g. example.com). Webhook path is built from provider and type.', max_length=255, verbose_name='Domain')),
                ('id', models.CharField(help_text='ID', verbose_name='ID')),
                ('type', models.CharField(choices=[('postal', 'Postal mail'), ('lre', 'Electronic registered letter'), ('ere', 'Electronic registered email (ERE)'), ('email', 'Email'), ('email_marketing', 'Marketing email'), ('sms', 'SMS'), ('rcs', 'RCS (Rich SMS)'), ('voice_call', 'Automated voice call'), ('notification', 'In-app notification'), ('push_notification', 'Mobile push notification'), ('branded', 'Branded App messaging (WhatsApp, Slack, etc.)')], help_text='Type', verbose_name='Type')),
                ('url', models.CharField(help_text='URL', verbose_name='URL')),
                ('description', models.CharField(help_text='Description', verbose_name='Description')),
                ('created_at', models.DateTimeField(help_text='Created At', verbose_name='Created At')),
                ('updated_at', models.DateTimeField(help_text='Updated At', verbose_name='Updated At')),
            ],
            options={
                'verbose_name': 'Webhook',
                'verbose_name_plural': 'Webhooks',
                'ordering': ['-created_at'],
                'managed': False,
            },
        ),
        migrations.CreateModel(
            name='Missive',
            fields=[
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
                ('thread_id', models.UUIDField(db_index=True, default=uuid.uuid4, editable=False, help_text='Thread ID for the missive', verbose_name='Thread')),
                ('thread_type', models.CharField(choices=[('missive', 'Missive'), ('message', 'Message'), ('history', 'History')], default='missive', help_text='Type of thread (missive, message, history)', max_length=50, verbose_name='Thread Type')),
                ('provider', django_providerkit.fields.ProviderField(blank=True, help_text='Provider used to send this missive', max_length=100, verbose_name='Provider')),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('processing', 'Processing'), ('success', 'Success'), ('failed', 'Failed'), ('error', 'Error'), ('cancelled', 'Cancelled')], default='draft', help_text='Current status of the missive', max_length=20, verbose_name='Status')),
                ('missive_support', models.CharField(choices=[('email', 'Email'), ('phone', 'Phone'), ('address', 'Address'), ('notification', 'Notification'), ('branded', 'Branded')], editable=False, help_text='Support for the missive (email, SMS, postal, etc.)', max_length=50, verbose_name='Missive Support')),
                ('brand_name', models.CharField(blank=True, help_text='Brand name used to send this missive', max_length=50, null=True, verbose_name='Brand Name')),
                ('missive_type', models.CharField(choices=[('postal', 'Postal mail'), ('lre', 'Electronic registered letter'), ('ere', 'Electronic registered email (ERE)'), ('email', 'Email'), ('email_marketing', 'Marketing email'), ('sms', 'SMS'), ('rcs', 'RCS (Rich SMS)'), ('voice_call', 'Automated voice call'), ('notification', 'In-app notification'), ('push_notification', 'Mobile push notification'), ('branded', 'Branded App messaging (WhatsApp, Slack, etc.)')], help_text='Type of missive (email, SMS, postal, etc.)', max_length=50, verbose_name='Missive Type')),
                ('acknowledgement', models.CharField(blank=True, choices=[('basic_delivery', 'Basic delivery'), ('acknowledgement_of_receipt', 'Acknowledgement of receipt')], help_text='Desired acknowledgement level for delivery proof', max_length=50, null=True, verbose_name='Acknowledgement Level')),
                ('delivery_mode', models.CharField(blank=True, choices=[('economic', 'Economic'), ('normal', 'Normal'), ('premium', 'Premium'), ('express', 'Express')], help_text='Delivery mode (email, SMS, postal, etc.)', max_length=50, null=True, verbose_name='Delivery Mode')),
                ('priority', models.CharField(blank=True, choices=[('low', 'Low'), ('normal', 'Normal'), ('high', 'High'), ('urgent', 'Urgent')], help_text='Priority level', max_length=20, null=True, verbose_name='Priority')),
                ('subject', models.CharField(blank=True, help_text='Subject line (for email, SMS, etc.)', max_length=500, null=True, verbose_name='Subject')),
                ('body_html', django_pymissive.fields.RichTextField(blank=True, help_text='HTML message body (email) or rich content (postal)', null=True, verbose_name='Body HTML')),
                ('body_text', models.TextField(blank=True, help_text='Plain text version of the message', null=True, verbose_name='Body Text')),
                ('sender_name', models.CharField(blank=True, help_text='Display name of the sender', max_length=255, null=True, verbose_name='Sender name')),
                ('sender_email', models.EmailField(blank=True, help_text='Email address of the sender', max_length=254, null=True, verbose_name='Sender email')),
                ('sender_phone', phonenumber_field.modelfields.PhoneNumberField(blank=True, help_text='Phone number of the sender (used for SMS)', max_length=128, null=True, region=None, verbose_name='Sender phone')),
                ('sender_address', django_geoaddress.fields.GeoaddressField(blank=True, help_text='Postal address of the sender', null=True, verbose_name='Sender address')),
                ('reply_to_name', models.CharField(blank=True, help_text='Display name for reply-to address', max_length=255, null=True, verbose_name='Reply-To name')),
                ('reply_to_email', models.EmailField(blank=True, help_text='Email address for replies', max_length=254, null=True, verbose_name='Reply-To email')),
                ('reply_to_address', django_geoaddress.fields.GeoaddressField(blank=True, help_text='Postal address for replies', max_length=512, null=True, verbose_name='Reply-To address')),
                ('additional_context', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional context as JSON', verbose_name='Additional context')),
                ('external_id', models.CharField(blank=True, editable=False, help_text='External identifier from the provider', max_length=255, null=True, verbose_name='External ID')),
                ('metadata', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional metadata as JSON', verbose_name='Metadata')),
                ('additional_config', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional configuration as JSON', verbose_name='Additional configuration')),
                ('webhook_url', models.URLField(blank=True, help_text='Webhook URL for the missive', max_length=255, null=True, verbose_name='Webhook URL')),
            ],
            options={
                'verbose_name': 'Missive',
                'verbose_name_plural': 'Missives',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='MissiveCampaign',
            fields=[
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
                ('subject', models.CharField(help_text='Campaign subject', max_length=255, verbose_name='Subject')),
                ('description', django_pymissive.fields.RichTextField(blank=True, help_text='Campaign description', verbose_name='Description')),
                ('acknowledgement_email', models.CharField(choices=[('basic_delivery', 'Basic delivery'), ('acknowledgement_of_receipt', 'Acknowledgement of receipt')], default='basic_delivery', help_text='Desired acknowledgement level for delivery proof', max_length=50, verbose_name='Acknowledgement Level')),
                ('sender_email_name', models.CharField(blank=True, help_text='Campaign sender email name', max_length=255, null=True, verbose_name='Sender email name')),
                ('sender_email', models.EmailField(blank=True, help_text='Campaign sender email', max_length=254, null=True, verbose_name='Sender email')),
                ('reply_to_email_name', models.CharField(blank=True, help_text='Display name for reply-to address', max_length=255, null=True, verbose_name='Reply-To name')),
                ('reply_to_email', models.EmailField(blank=True, help_text='Email address for replies', max_length=254, null=True, verbose_name='Reply-To email')),
                ('body_html', django_pymissive.fields.RichTextField(blank=True, help_text='Campaign email HTML body', verbose_name='Body HTML')),
                ('body_text', models.TextField(blank=True, help_text='Campaign body text', verbose_name='Body text')),
                ('sender_phone_name', models.CharField(blank=True, help_text='Campaign sender phone name', max_length=255, null=True, verbose_name='Sender phone name')),
                ('sender_phone', phonenumber_field.modelfields.PhoneNumberField(blank=True, help_text='Phone number of the sender (used for SMS)', max_length=128, null=True, region=None, verbose_name='Sender phone')),
                ('body_sms', models.TextField(blank=True, help_text='Campaign body SMS', verbose_name='Body SMS')),
                ('sender_address_name', models.CharField(blank=True, help_text='Campaign sender address name', max_length=255, null=True, verbose_name='Sender address name')),
                ('sender_address', django_geoaddress.fields.GeoaddressField(blank=True, help_text='Campaign sender address', null=True, verbose_name='Sender address')),
                ('reply_to_address_name', models.CharField(blank=True, help_text='Display name for reply-to address', max_length=255, null=True, verbose_name='Reply-To address name')),
                ('reply_to_address', django_geoaddress.fields.GeoaddressField(blank=True, help_text='Postal address for replies', max_length=512, null=True, verbose_name='Reply-To address')),
                ('acknowledgement_postal', models.CharField(choices=[('basic_delivery', 'Basic delivery'), ('acknowledgement_of_receipt', 'Acknowledgement of receipt')], default='basic_delivery', help_text='Desired acknowledgement level for delivery proof', max_length=50, verbose_name='Acknowledgement Level')),
                ('delivery_mode_postal', models.CharField(choices=[('economic', 'Economic'), ('normal', 'Normal'), ('premium', 'Premium'), ('express', 'Express')], default='normal', help_text='Delivery mode (email, SMS, postal, etc.)', max_length=50, verbose_name='Delivery Mode')),
                ('priority_postal', models.CharField(choices=[('low', 'Low'), ('normal', 'Normal'), ('high', 'High'), ('urgent', 'Urgent')], default='normal', help_text='Priority level', max_length=20, verbose_name='Priority')),
                ('body_postal', django_pymissive.fields.RichTextField(blank=True, help_text='Campaign body Postal', verbose_name='Body Postal')),
                ('additional_context', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional context as JSON', verbose_name='Additional context')),
                ('additional_config', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional configuration as JSON', verbose_name='Additional configuration')),
                ('metadata', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional metadata as JSON', verbose_name='Metadata')),
            ],
            options={
                'verbose_name': 'Campaign',
                'verbose_name_plural': 'Campaigns',
                'ordering': [],
            },
        ),
        migrations.CreateModel(
            name='MissiveConfig',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('missive_type', models.CharField(choices=[('postal', 'Postal mail'), ('lre', 'Electronic registered letter'), ('ere', 'Electronic registered email (ERE)'), ('email', 'Email'), ('email_marketing', 'Marketing email'), ('sms', 'SMS'), ('rcs', 'RCS (Rich SMS)'), ('voice_call', 'Automated voice call'), ('notification', 'In-app notification'), ('push_notification', 'Mobile push notification'), ('branded', 'Branded App messaging (WhatsApp, Slack, etc.)')], help_text='Type of missive (email, sms, postal, etc.)', max_length=50, unique=True, verbose_name='Missive type')),
                ('default_provider', django_providerkit.fields.ProviderField(blank=True, help_text='Provider name (e.g. brevo, sendgrid). Leave empty for no default.', max_length=100, verbose_name='Default provider')),
            ],
            options={
                'verbose_name': 'Configuration',
                'verbose_name_plural': 'Configurations',
                'ordering': ['missive_type'],
            },
        ),
        migrations.CreateModel(
            name='MissiveHistory',
            fields=[
            ],
            options={
                'verbose_name': 'Missive History',
                'verbose_name_plural': 'Missive Histories',
                'ordering': ['-created_at'],
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missive',),
        ),
        migrations.CreateModel(
            name='MissiveMessage',
            fields=[
            ],
            options={
                'verbose_name': 'Missive Message',
                'verbose_name_plural': 'Missive Messages',
                'ordering': ['-created_at'],
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missive',),
        ),
        migrations.CreateModel(
            name='MissiveBaseAttachment',
            fields=[
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, verbose_name='ID')),
                ('attachment_type', models.CharField(choices=[('virtual_attachment', 'Virtual Attachment'), ('attachment', 'Attachment'), ('signature', 'Signature'), ('receipt', 'Receipt'), ('proof', 'Proof'), ('other', 'Other')], default='attachment', help_text='Type of attachment (attachment, signature, receipt, proof, other)', max_length=50, verbose_name='Attachment Type')),
                ('attachment_object_id', models.PositiveIntegerField(blank=True, help_text='ID of the object to which this file is attached', null=True, verbose_name='Object ID')),
                ('attachment_object_arguments', django_pymissive.fields.JSONField(blank=True, default={'args': [], 'kwargs': {}, 'method': 'get_attachment'}, help_text='Arguments to pass to the file method (as dict for **kwargs)', verbose_name='Attachment Object Arguments')),
                ('attachment_file', models.FileField(blank=True, help_text='Leave blank if the attachment is hosted externally', null=True, upload_to=django_pymissive.models.attachment._attachment_upload_to, verbose_name='Attachment File')),
                ('metadata', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional metadata as JSON', verbose_name='Metadata')),
                ('linked', models.BooleanField(default=True, help_text='Indicates if the attachment is linked to a related object', verbose_name='Linked')),
                ('priority', models.PositiveIntegerField(default=1, help_text='Page order (1=first page from letter body, attachments start at 2)', verbose_name='Priority')),
                ('external_id', models.CharField(blank=True, help_text='External ID of the attachment', max_length=255, null=True, verbose_name='External ID')),
                ('page_count', models.PositiveIntegerField(blank=True, help_text='Number of pages in the document', null=True, verbose_name='Page count')),
                ('attachment_content_type', models.ForeignKey(blank=True, help_text='Type of model to which this file is attached', null=True, on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='Object Type')),
                ('missive', models.ForeignKey(blank=True, help_text='Missive to which this file is attached', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='to_missiveattachment', to='django_pymissive.missive', verbose_name='Missive')),
                ('campaign', models.ForeignKey(blank=True, help_text='Campaign to which this file is attached', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='to_campaigndocument', to='django_pymissive.missivecampaign', verbose_name='Campaign')),
            ],
            options={
                'verbose_name': 'Attachment',
                'verbose_name_plural': 'Attachments',
                'ordering': ['priority'],
            },
        ),
        migrations.CreateModel(
            name='CampaignAttachment',
            fields=[
            ],
            options={
                'verbose_name': 'Campaign Attachment',
                'verbose_name_plural': 'Campaign Attachments',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missivebaseattachment',),
        ),
        migrations.CreateModel(
            name='CampaignVirtualAttachment',
            fields=[
            ],
            options={
                'verbose_name': 'Campaign Virtual Attachment',
                'verbose_name_plural': 'Campaign Virtual Attachments',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missivebaseattachment',),
        ),
        migrations.CreateModel(
            name='MissiveAttachment',
            fields=[
            ],
            options={
                'verbose_name': 'Attachment',
                'verbose_name_plural': 'Attachments',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missivebaseattachment',),
        ),
        migrations.CreateModel(
            name='MissiveVirtualAttachment',
            fields=[
            ],
            options={
                'verbose_name': 'Virtual Attachment',
                'verbose_name_plural': 'Virtual Attachments',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missivebaseattachment',),
        ),
        migrations.AddField(
            model_name='missive',
            name='campaign',
            field=models.ForeignKey(blank=True, help_text='Optional campaign this missive belongs to', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='to_missive', to='django_pymissive.missivecampaign', verbose_name='Campaign'),
        ),
        migrations.CreateModel(
            name='CampaignRelatedObject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('object_id', models.PositiveIntegerField(help_text='ID of the related object', verbose_name='Object ID')),
                ('object_str', models.CharField(editable=False, help_text='String representation of the related object (saved for reference if object is deleted)', max_length=500, verbose_name='Object String Representation')),
                ('content_type', models.ForeignKey(help_text='Type of the related object', on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='Content Type')),
                ('campaign', models.ForeignKey(help_text='Campaign to which this object is related', on_delete=django.db.models.deletion.CASCADE, related_name='to_campaignrelatedobject', to='django_pymissive.missivecampaign', verbose_name='Campaign')),
            ],
            options={
                'verbose_name': 'Campaign Related Object',
                'verbose_name_plural': 'Campaign Related Objects',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='MissiveRecipient',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('recipient_support', models.CharField(blank=True, choices=[('email', 'Email'), ('phone', 'Phone'), ('address', 'Address'), ('notification', 'Notification'), ('branded', 'Branded')], help_text='Model of recipient', max_length=255, null=True, verbose_name='Recipient Model')),
                ('recipient_type', models.CharField(choices=[('recipient', 'Recipient'), ('cc', 'CC'), ('bcc', 'BCC')], default='recipient', help_text='Type of recipient', max_length=20, verbose_name='Recipient Type')),
                ('status', models.CharField(choices=[('draft', 'Draft'), ('processing', 'Processing'), ('success', 'Success'), ('failed', 'Failed'), ('error', 'Error'), ('cancelled', 'Cancelled')], default='draft', help_text='Current status of the missive', max_length=20, verbose_name='Status')),
                ('name', models.CharField(blank=True, help_text='Full name or company name', max_length=255, verbose_name='Name')),
                ('email', models.EmailField(blank=True, help_text="Recipient's email address", max_length=254, null=True, verbose_name='Recipient Email')),
                ('phone', phonenumber_field.modelfields.PhoneNumberField(blank=True, help_text='Phone number', max_length=20, null=True, region=None, verbose_name='Phone')),
                ('address', django_geoaddress.fields.GeoaddressField(blank=True, help_text='Address', null=True, verbose_name='Address')),
                ('notification_id', models.CharField(blank=True, help_text='Notification ID', max_length=255, null=True, verbose_name='Notification ID')),
                ('external_id', models.CharField(blank=True, help_text='External identifier from the provider', max_length=255, null=True, verbose_name='External ID')),
                ('sent_at', models.DateTimeField(blank=True, help_text='When the missive was sent', null=True, verbose_name='Sent At')),
                ('delivered_at', models.DateTimeField(blank=True, help_text='When the missive was delivered', null=True, verbose_name='Delivered At')),
                ('missive', models.ForeignKey(help_text='Missive', on_delete=django.db.models.deletion.CASCADE, related_name='to_missiverecipient', to='django_pymissive.missive', verbose_name='Missive')),
            ],
            options={
                'verbose_name': 'Recipient',
                'verbose_name_plural': 'Recipients',
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='MissiveEvent',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('provider', django_providerkit.fields.ProviderField(blank=True, help_text='Provider that emitted this event', max_length=100, null=True, verbose_name='Provider')),
                ('event', models.CharField(blank=True, choices=[('delivered', 'Delivered'), ('read', 'Read'), ('opened', 'Opened'), ('click', 'Clicked'), ('clicked', 'Clicked'), ('proofs_of_delivery', 'Proofs of Delivery'), ('untreated', 'Untreated'), ('draft', 'Draft'), ('sent', 'Sent'), ('prepare', 'Prepare'), ('pending', 'Pending'), ('processing', 'Processing'), ('queued', 'Queued'), ('request', 'Request'), ('deferred', 'Deferred'), ('scheduled', 'Scheduled'), ('unknown_type', 'Unknown type'), ('attempted_delivery', 'Attempted delivery'), ('mailed', 'Mailed'), ('printed', 'Printed'), ('accepted', 'Accepted'), ('dispatched', 'Dispatched'), ('shipped', 'Shipped'), ('in_transit', 'In transit'), ('deposit_proof', 'Deposit Proof'), ('proof_of_content', 'Proof of Content'), ('archived', 'Archived'), ('failed', 'Failed'), ('cancelled', 'Cancelled'), ('bounced', 'Bounced'), ('hard_bounce', 'Hard bounce'), ('soft_bounce', 'Soft bounce'), ('dropped', 'Dropped'), ('spam', 'Spam'), ('blocked', 'Blocked'), ('invalid', 'Invalid'), ('mailbox_not_found', 'Mailbox not found'), ('blocklisted', 'Blocklisted'), ('blocklist_created', 'Blocklist created'), ('rejected', 'Rejected'), ('undelivered', 'Undelivered'), ('undeliverable', 'Undeliverable'), ('expired', 'Expired'), ('carrier_rejected', 'Carrier rejected'), ('return_to_sender', 'Return to sender'), ('refused', 'Refused'), ('lost', 'Lost'), ('damaged', 'Damaged'), ('out_for_delivery', 'Out for delivery'), ('error', 'Error')], help_text='Event type (sent, delivered, read, failed, etc.)', max_length=50, null=True, verbose_name='Event')),
                ('description', models.TextField(blank=True, help_text='Description or details about this event', verbose_name='Description')),
                ('metadata', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional metadata as JSON', verbose_name='Metadata')),
                ('trace', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Raw trace data (webhook payload, API response, etc.)', verbose_name='Trace')),
                ('user_action', models.BooleanField(default=False, help_text='Indicates if the event was triggered by a user action', verbose_name='User Action')),
                ('occurred_at', models.DateTimeField(help_text='When this event occurred', verbose_name='Occurred At')),
                ('is_billed', models.BooleanField(default=False, help_text='Indicates if the missive has been billed', verbose_name='Billed')),
                ('billing_amount', models.DecimalField(blank=True, decimal_places=3, help_text='Amount billed for the missive', max_digits=10, null=True, verbose_name='Billing Amount')),
                ('estimate_amount', models.DecimalField(blank=True, decimal_places=3, help_text='Estimated amount for the missive', max_digits=10, null=True, verbose_name='Estimate Amount')),
                ('missive', models.ForeignKey(blank=True, editable=False, help_text='Missive associated with this event', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='to_missiveevent', to='django_pymissive.missive', verbose_name='Missive')),
                ('recipient', models.ForeignKey(blank=True, editable=False, help_text='Recipient associated with this event', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='to_recipientevent', to='django_pymissive.missiverecipient', verbose_name='Recipient')),
            ],
            options={
                'verbose_name': 'Event',
                'verbose_name_plural': 'Events',
                'ordering': ['-occurred_at'],
            },
        ),
        migrations.AddField(
            model_name='missive',
            name='message_by',
            field=models.ForeignKey(blank=True, help_text='Recipient who sent this reply (for inbound exchanges)', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='to_missivemessageby', to='django_pymissive.missiverecipient', verbose_name='Reply by'),
        ),
        migrations.CreateModel(
            name='MissiveRecipientAddress',
            fields=[
            ],
            options={
                'verbose_name': 'Address Recipient',
                'verbose_name_plural': 'Address Recipients',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missiverecipient',),
        ),
        migrations.CreateModel(
            name='MissiveRecipientEmail',
            fields=[
            ],
            options={
                'verbose_name': 'Email Recipient',
                'verbose_name_plural': 'Email Recipients',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missiverecipient',),
        ),
        migrations.CreateModel(
            name='MissiveRecipientNotification',
            fields=[
            ],
            options={
                'verbose_name': 'Notification Recipient',
                'verbose_name_plural': 'Notification Recipients',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missiverecipient',),
        ),
        migrations.CreateModel(
            name='MissiveRecipientPhone',
            fields=[
            ],
            options={
                'verbose_name': 'Phone Recipient',
                'verbose_name_plural': 'Phone Recipients',
                'proxy': True,
                'indexes': [],
                'constraints': [],
            },
            bases=('django_pymissive.missiverecipient',),
        ),
        migrations.CreateModel(
            name='MissiveRelatedObject',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('object_id', models.PositiveIntegerField(help_text='ID of the related object', verbose_name='Object ID')),
                ('object_str', models.CharField(editable=False, help_text='String representation of the related object (saved for reference if object is deleted)', max_length=500, verbose_name='Object String Representation')),
                ('content_type', models.ForeignKey(help_text='Type of the related object', on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='Content Type')),
                ('missive', models.ForeignKey(help_text='Missive to which this object is related', on_delete=django.db.models.deletion.CASCADE, related_name='to_missiverelatedobject', to='django_pymissive.missive', verbose_name='Missive')),
            ],
            options={
                'verbose_name': 'Missive Related Object',
                'verbose_name_plural': 'Missive Related Objects',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='MissiveScheduledCampaign',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField(blank=True, help_text='Internal comment or note', null=True, verbose_name='Comment')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created At')),
                ('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated At')),
                ('scheduled_send_date', models.DateTimeField(blank=True, help_text='Scheduled send date for the campaign (leave blank for immediate sending)', null=True, verbose_name='Scheduled send date')),
                ('send_date', models.DateTimeField(blank=True, editable=False, help_text='Actual send date for the campaign', null=True, verbose_name='Send date')),
                ('ended_at', models.DateTimeField(blank=True, editable=False, help_text='Actual ended date for the campaign', null=True, verbose_name='Ended at')),
                ('additional_config', django_pymissive.fields.JSONField(blank=True, default=dict, help_text='Additional configuration as JSON', verbose_name='Additional configuration')),
                ('campaign', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, related_name='to_missivecampaignsend', to='django_pymissive.missivecampaign', verbose_name='Campaign')),
            ],
            options={
                'verbose_name': 'Campaign send',
                'verbose_name_plural': 'Campaign sends',
                'ordering': ['-scheduled_send_date', '-ended_at', '-id'],
            },
        ),
    ]
