# Generated by Django 5.1.5 on 2025-09-11 08:53

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


class Migration(migrations.Migration):

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

    operations = [
        migrations.CreateModel(
            name="NotificationHistory",
            fields=[
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="Timestamp when this record was created",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        help_text="Timestamp when this record was last modified",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        help_text="Unique identifier for this record",
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "action_type",
                    models.CharField(
                        choices=[
                            ("delivered", "Delivered"),
                            ("read", "Read"),
                            ("clicked", "Clicked"),
                            ("dismissed", "Dismissed"),
                            ("unsubscribed", "Unsubscribed"),
                        ],
                        help_text="Type of action performed",
                        max_length=20,
                    ),
                ),
                (
                    "action_data",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        help_text="Additional data about the action",
                    ),
                ),
                (
                    "ip_address",
                    models.GenericIPAddressField(
                        blank=True, help_text="IP address of the user", null=True
                    ),
                ),
                (
                    "user_agent",
                    models.TextField(blank=True, help_text="User agent string"),
                ),
                (
                    "notification",
                    models.ForeignKey(
                        help_text="Notification this history entry relates to",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="history",
                        to="notifications.notification",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="User who performed the action",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notification_history",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Notification History",
                "verbose_name_plural": "Notification Histories",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(
                        fields=["notification", "action_type"],
                        name="notificatio_notific_356237_idx",
                    ),
                    models.Index(
                        fields=["user", "action_type"],
                        name="notificatio_user_id_41e3bf_idx",
                    ),
                    models.Index(
                        fields=["created_at"], name="notificatio_created_ba4873_idx"
                    ),
                ],
            },
        ),
        migrations.CreateModel(
            name="NotificationPreference",
            fields=[
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="Timestamp when this record was created",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        help_text="Timestamp when this record was last modified",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        help_text="Unique identifier for this record",
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "event_type",
                    models.CharField(
                        choices=[
                            ("jingle_detected", "Jingle Detected"),
                            ("ad_break_started", "Ad Break Started"),
                            ("ad_break_ended", "Ad Break Ended"),
                            ("stream_started", "Stream Started"),
                            ("stream_stopped", "Stream Stopped"),
                            ("stream_error", "Stream Error"),
                            ("high_error_rate", "High Error Rate"),
                            ("system_startup", "System Startup"),
                            ("system_shutdown", "System Shutdown"),
                        ],
                        help_text="Type of event for this preference",
                        max_length=30,
                    ),
                ),
                (
                    "channel_types",
                    models.JSONField(
                        default=list, help_text="Preferred notification channel types"
                    ),
                ),
                (
                    "is_enabled",
                    models.BooleanField(
                        default=True,
                        help_text="Whether notifications are enabled for this event type",
                    ),
                ),
                (
                    "quiet_hours_start",
                    models.TimeField(
                        blank=True,
                        help_text="Start of quiet hours (no notifications)",
                        null=True,
                    ),
                ),
                (
                    "quiet_hours_end",
                    models.TimeField(
                        blank=True, help_text="End of quiet hours", null=True
                    ),
                ),
                (
                    "frequency_limit",
                    models.PositiveIntegerField(
                        default=0,
                        help_text="Maximum notifications per hour (0 = unlimited)",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="User who owns these preferences",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notification_preferences",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Notification Preference",
                "verbose_name_plural": "Notification Preferences",
                "indexes": [
                    models.Index(
                        fields=["user", "event_type"],
                        name="notificatio_user_id_a544c1_idx",
                    ),
                    models.Index(
                        fields=["is_enabled"], name="notificatio_is_enab_cd097c_idx"
                    ),
                ],
                "unique_together": {("user", "event_type")},
            },
        ),
        migrations.CreateModel(
            name="NotificationSubscription",
            fields=[
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="Timestamp when this record was created",
                    ),
                ),
                (
                    "updated_at",
                    models.DateTimeField(
                        auto_now=True,
                        help_text="Timestamp when this record was last modified",
                    ),
                ),
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        help_text="Unique identifier for this record",
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                (
                    "object_id",
                    models.PositiveIntegerField(
                        help_text="ID of the object being subscribed to"
                    ),
                ),
                (
                    "event_types",
                    models.JSONField(
                        default=list, help_text="List of event types to subscribe to"
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        default=True, help_text="Whether this subscription is active"
                    ),
                ),
                (
                    "content_type",
                    models.ForeignKey(
                        help_text="Type of object being subscribed to",
                        on_delete=django.db.models.deletion.CASCADE,
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        help_text="User who created this subscription",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="notification_subscriptions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Notification Subscription",
                "verbose_name_plural": "Notification Subscriptions",
                "indexes": [
                    models.Index(
                        fields=["user", "is_active"],
                        name="notificatio_user_id_485618_idx",
                    ),
                    models.Index(
                        fields=["content_type", "object_id"],
                        name="notificatio_content_f9315b_idx",
                    ),
                ],
                "unique_together": {("user", "content_type", "object_id")},
            },
        ),
    ]
