# Generated by Django 5.2.9 on 2026-01-05 14:36

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


class Migration(migrations.Migration):

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
        ("notifications", "0001_initial"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AlterField(
            model_name="subscriber",
            name="novu_subscriber_id",
            field=models.CharField(
                db_index=True, help_text="Legacy Novu subscriber ID (deprecated)", max_length=255, unique=True
            ),
        ),
        migrations.CreateModel(
            name="Notification",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("verb", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True)),
                (
                    "level",
                    models.CharField(
                        choices=[("info", "Info"), ("success", "Success"), ("warning", "Warning"), ("error", "Error")],
                        default="info",
                        max_length=20,
                    ),
                ),
                ("action_object_id", models.PositiveIntegerField(blank=True, null=True)),
                ("target_id", models.PositiveIntegerField(blank=True, null=True)),
                ("data", models.JSONField(blank=True, default=dict)),
                ("unread", models.BooleanField(db_index=True, default=True)),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                ("read_at", models.DateTimeField(blank=True, null=True)),
                (
                    "action_object_content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notification_action_objects",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "actor",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="notifications_sent",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "recipient",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="in_app_notifications",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "target_content_type",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notification_targets",
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "verbose_name": "Notification",
                "verbose_name_plural": "Notifications",
                "ordering": ["-timestamp"],
                "indexes": [
                    models.Index(fields=["recipient", "-timestamp"], name="notificatio_recipie_b8fa2a_idx"),
                    models.Index(fields=["recipient", "unread"], name="notificatio_recipie_8bedf2_idx"),
                ],
            },
        ),
    ]
