# Generated by Django 4.2.3 on 2023-07-16 07:12

import uuid

import django.core.serializers.json
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="TokenUserVisit",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "timestamp",
                    models.DateTimeField(
                        default=django.utils.timezone.now,
                        help_text="The time at which the first visit of the day was recorded",
                    ),
                ),
                (
                    "session_key",
                    models.CharField(
                        blank=True,
                        help_text="Django session identifier",
                        max_length=40,
                        null=True,
                    ),
                ),
                (
                    "token_key",
                    models.CharField(
                        blank=True,
                        help_text="Auth Token identifier",
                        max_length=40,
                        null=True,
                    ),
                ),
                (
                    "remote_addr",
                    models.CharField(
                        blank=True,
                        help_text="Client IP address (from X-Forwarded-For HTTP header, or REMOTE_ADDR request property)",
                        max_length=100,
                    ),
                ),
                (
                    "ua_string",
                    models.TextField(
                        blank=True,
                        help_text="Client User-Agent HTTP header",
                        verbose_name="User agent (raw)",
                    ),
                ),
                (
                    "uuid",
                    models.UUIDField(default=uuid.uuid4, editable=False, unique=True),
                ),
                (
                    "hash",
                    models.CharField(
                        help_text="MD5 hash generated from request properties",
                        max_length=32,
                        unique=True,
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(
                        auto_now_add=True,
                        help_text="The time at which the database record was created (!=timestamp)",
                    ),
                ),
                (
                    "context",
                    models.JSONField(
                        blank=True,
                        default=dict,
                        encoder=django.core.serializers.json.DjangoJSONEncoder,
                        help_text="Used for storing ad hoc / ephemeral data - e.g. GeoIP.",
                        null=True,
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="token_user_visits",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "get_latest_by": "timestamp",
            },
        ),
    ]
