# Generated 2026-05-04 — FRREP-DCI012 (inbound email-to-repository ingestion)

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("repository_documents", "0004_collection_slug_alias"),
    ]

    operations = [
        migrations.AddField(
            model_name="collection",
            name="email_ingest_enabled",
            field=models.BooleanField(
                default=False,
                help_text="Allow new documents to be submitted by emailing them to this collection's inbox address.",
            ),
        ),
        migrations.AddField(
            model_name="collection",
            name="email_ingest_address",
            field=models.EmailField(
                blank=True,
                help_text="Mailbox address that maps to this collection — e.g. repo+theses@iilmp.org.",
                max_length=254,
            ),
        ),
        migrations.AddField(
            model_name="collection",
            name="email_ingest_allowed_senders",
            field=models.TextField(
                blank=True,
                help_text="Newline-separated email addresses or domains (@example.org) allowed to submit. Leave empty to deny all.",
            ),
        ),
        migrations.AddConstraint(
            model_name="collection",
            constraint=models.UniqueConstraint(
                condition=models.Q(("email_ingest_enabled", True)),
                fields=("email_ingest_address",),
                name="uniq_collection_email_ingest_addr_when_enabled",
            ),
        ),
    ]
