# Generated by Django 5.2.9 on 2025-12-15 15:07

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="PushSubscription",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "endpoint",
                    models.URLField(
                        db_index=True,
                        help_text="Push service endpoint URL",
                        max_length=500,
                        unique=True,
                    ),
                ),
                (
                    "p256dh",
                    models.CharField(help_text="P256DH encryption key (base64)", max_length=255),
                ),
                ("auth", models.CharField(help_text="Auth secret (base64)", max_length=255)),
                (
                    "is_active",
                    models.BooleanField(
                        db_index=True, default=True, help_text="Whether subscription is active"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True, db_index=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "user",
                    models.ForeignKey(
                        help_text="User owning this subscription",
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="push_subscriptions",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "verbose_name": "Push Subscription",
                "verbose_name_plural": "Push Subscriptions",
                "db_table": "django_cfg_push_subscription",
                "ordering": ["-created_at"],
                "indexes": [
                    models.Index(
                        fields=["user", "-created_at"], name="django_cfg__user_id_885bcb_idx"
                    ),
                    models.Index(
                        fields=["is_active", "-created_at"], name="django_cfg__is_acti_05a675_idx"
                    ),
                ],
            },
        ),
    ]
