# Generated by Django 5.2.13 on 2026-04-23 16:35

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


class Migration(migrations.Migration):

    dependencies = [
        ("rims_operations", "0002_add_partner_type"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Donor",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("name", models.CharField(db_index=True, max_length=255)),
                (
                    "donor_type",
                    models.CharField(
                        blank=True,
                        choices=[
                            ("bilateral", "Bilateral agency"),
                            ("multilateral", "Multilateral agency"),
                            ("foundation", "Foundation"),
                            ("corporate", "Corporate sponsor"),
                            ("government", "Government body"),
                            ("individual", "Individual donor"),
                            ("other", "Other"),
                        ],
                        max_length=16,
                    ),
                ),
                ("country", models.CharField(blank=True, max_length=2)),
                ("contact_email", models.EmailField(blank=True, max_length=254)),
                ("contact_phone", models.CharField(blank=True, max_length=64)),
                ("website", models.URLField(blank=True)),
                ("notes", models.TextField(blank=True)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                (
                    "created_by",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="donors_created",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "partner",
                    models.ForeignKey(
                        blank=True,
                        help_text="Optional link to the Partner taxonomy when this donor is also tracked there.",
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="donor_profiles",
                        to="rims_operations.partner",
                    ),
                ),
            ],
            options={
                "ordering": ["name"],
                "constraints": [
                    models.UniqueConstraint(
                        fields=("name", "country"), name="uniq_donor_name_country"
                    )
                ],
            },
        ),
    ]
