# Generated by Django 4.2.23 on 2025-11-01 12:14

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("indy_hub", "0039_alter_charactersettings_copy_sharing_scope_and_more"),
    ]

    operations = [
        migrations.AddField(
            model_name="charactersettings",
            name="jobs_last_digest_at",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="charactersettings",
            name="jobs_next_digest_at",
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name="charactersettings",
            name="jobs_notify_custom_days",
            field=models.PositiveSmallIntegerField(default=3),
        ),
        migrations.AddField(
            model_name="charactersettings",
            name="jobs_notify_frequency",
            field=models.CharField(
                choices=[
                    ("disabled", "Disabled"),
                    ("immediate", "Immediate"),
                    ("daily", "Daily digest"),
                    ("weekly", "Weekly digest"),
                    ("monthly", "Monthly digest"),
                    ("custom", "Custom cadence"),
                ],
                default="disabled",
                max_length=20,
            ),
        ),
        migrations.CreateModel(
            name="JobNotificationDigestEntry",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("job_id", models.BigIntegerField()),
                ("payload", models.JSONField(blank=True, default=dict)),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("sent_at", models.DateTimeField(blank=True, null=True)),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="indy_job_notification_entries",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "default_permissions": (),
                "indexes": [
                    models.Index(
                        fields=["user", "sent_at"], name="job_digest_user_sent_idx"
                    )
                ],
            },
        ),
        migrations.AddConstraint(
            model_name="jobnotificationdigestentry",
            constraint=models.UniqueConstraint(
                fields=("user", "job_id"), name="job_digest_user_job_uq"
            ),
        ),
    ]
