# Generated by Django 4.2.26 on 2026-01-22 13:44
import uuid

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

import pretix.base.models.mail


class Migration(migrations.Migration):

    dependencies = [
        ("pretixbase", "0296_invoice_invoice_from_state"),
    ]

    operations = [
        migrations.CreateModel(
            name="OutgoingMail",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False
                    ),
                ),
                ("guid", models.UUIDField(db_index=True, default=uuid.uuid4)),
                ("status", models.CharField(default="queued", max_length=200)),
                ("created", models.DateTimeField(auto_now_add=True)),
                ("sent", models.DateTimeField(blank=True, null=True)),
                ("inflight_since", models.DateTimeField(blank=True, null=True)),
                ("retry_after", models.DateTimeField(blank=True, null=True)),
                ("error", models.TextField(null=True)),
                ("error_detail", models.TextField(null=True)),
                ("sensitive", models.BooleanField(default=False)),
                ("subject", models.TextField()),
                ("body_plain", models.TextField()),
                ("body_html", models.TextField(null=True)),
                ("sender", models.CharField(max_length=500)),
                ("headers", models.JSONField(default=dict)),
                ("to", models.JSONField(default=list)),
                ("cc", models.JSONField(default=list)),
                ("bcc", models.JSONField(default=list)),
                ("recipient_count", models.IntegerField()),
                ("should_attach_tickets", models.BooleanField(default=False)),
                ("should_attach_ical", models.BooleanField(default=False)),
                ("should_attach_other_files", models.JSONField(default=list)),
                ("actual_attachments", models.JSONField(default=list)),
                (
                    "customer",
                    models.ForeignKey(
                        null=True,
                        on_delete=pretix.base.models.mail.CASCADE_IF_QUEUED,
                        related_name="outgoing_mails",
                        to="pretixbase.customer",
                    ),
                ),
                (
                    "event",
                    models.ForeignKey(
                        null=True,
                        on_delete=pretix.base.models.mail.CASCADE_IF_QUEUED,
                        related_name="outgoing_mails",
                        to="pretixbase.event",
                    ),
                ),
                (
                    "order",
                    models.ForeignKey(
                        null=True,
                        on_delete=pretix.base.models.mail.CASCADE_IF_QUEUED,
                        related_name="outgoing_mails",
                        to="pretixbase.order",
                    ),
                ),
                (
                    "orderposition",
                    models.ForeignKey(
                        null=True,
                        on_delete=pretix.base.models.mail.CASCADE_IF_QUEUED,
                        related_name="outgoing_mails",
                        to="pretixbase.orderposition",
                    ),
                ),
                (
                    "organizer",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="outgoing_mails",
                        to="pretixbase.organizer",
                    ),
                ),
                (
                    "should_attach_cached_files",
                    models.ManyToManyField(
                        related_name="outgoing_mails", to="pretixbase.cachedfile"
                    ),
                ),
                (
                    "should_attach_invoices",
                    models.ManyToManyField(
                        related_name="outgoing_mails", to="pretixbase.invoice"
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="outgoing_mails",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "ordering": ("-created",),
            },
        ),
    ]
