# Generated by Django 5.1.3 on 2026-05-29 07:50

import django.db.models.deletion
import uuid
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ("organizations", "0001_initial"),
        ("platform_core", "0004_note"),
        ("tenants", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Mention",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True, db_index=True, verbose_name="created at"
                    ),
                ),
                ("updated_at", models.DateTimeField(auto_now=True, verbose_name="updated at")),
                (
                    "public_id",
                    models.UUIDField(
                        db_index=True,
                        default=uuid.uuid4,
                        editable=False,
                        unique=True,
                        verbose_name="public id",
                    ),
                ),
                ("notified", models.BooleanField(default=False, verbose_name="notified")),
                (
                    "comment",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="mention_records",
                        to="platform_core.comment",
                    ),
                ),
                (
                    "note",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="mention_records",
                        to="platform_core.note",
                    ),
                ),
                (
                    "organization_node",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="+",
                        to="organizations.organizationnode",
                        verbose_name="organization node",
                    ),
                ),
                (
                    "tenant",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="tenants.tenant",
                        verbose_name="tenant",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="mentioned user",
                    ),
                ),
            ],
            options={
                "verbose_name": "mention",
                "verbose_name_plural": "mentions",
                "indexes": [
                    models.Index(fields=["tenant", "user"], name="platform_co_tenant__b46583_idx"),
                    models.Index(
                        fields=["tenant", "comment"], name="platform_co_tenant__40bf9a_idx"
                    ),
                    models.Index(fields=["tenant", "note"], name="platform_co_tenant__cb936e_idx"),
                ],
                "constraints": [
                    models.UniqueConstraint(
                        condition=models.Q(("comment__isnull", False)),
                        fields=("comment", "user"),
                        name="platform_core_mention_unique_comment_user",
                    ),
                    models.UniqueConstraint(
                        condition=models.Q(("note__isnull", False)),
                        fields=("note", "user"),
                        name="platform_core_mention_unique_note_user",
                    ),
                ],
            },
        ),
    ]
