# Generated by Django 5.2.4 on 2025-08-08 12:34

import uuid
import django.db.models.deletion
import django.utils.timezone
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="UserSession",
            fields=[
                (
                    "id",
                    models.CharField(default=uuid.uuid4, max_length=36, primary_key=True, serialize=False),
                ),
                (
                    "jti",
                    models.UUIDField(unique=True, verbose_name="JWT ID"),
                ),
                (
                    "user_agent",
                    models.TextField(blank=True, null=True, verbose_name="User Agent"),
                ),
                (
                    "ip_address",
                    models.GenericIPAddressField(
                        blank=True, null=True, verbose_name="IP Address"
                    ),
                ),
                (
                    "referer",
                    models.URLField(blank=True, null=True, verbose_name="Referer"),
                ),
                ("exp", models.DateTimeField(verbose_name="Expiration Time")),
                (
                    "created_at",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="Created At"
                    ),
                ),
                (
                    "last_activity",
                    models.DateTimeField(
                        default=django.utils.timezone.now, verbose_name="Last Activity"
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(default=True, verbose_name="Is Active"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sessions",
                        to=settings.AUTH_USER_MODEL,
                        verbose_name="User",
                    ),
                ),
            ],
            options={
                "verbose_name": "User Session",
                "verbose_name_plural": "User Sessions",
                "ordering": ["-last_activity"],
            },
        ),
    ]
