# Generated by Django 5.2 on 2025-10-02 15:57

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


class Migration(migrations.Migration):

    dependencies = [
        ('api', '0149_add_homepage_templates'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='PersistentAgentWebSession',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('session_key', models.UUIDField(default=uuid.uuid4, editable=False, unique=True)),
                ('started_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('last_seen_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('last_seen_source', models.CharField(blank=True, max_length=32)),
                ('ended_at', models.DateTimeField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('agent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='web_sessions', to='api.persistentagent')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='agent_web_sessions', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'indexes': [models.Index(fields=['agent', 'last_seen_at'], name='pa_web_session_agent_idx'), models.Index(fields=['session_key'], name='pa_web_session_key_idx'), models.Index(fields=['ended_at', 'last_seen_at'], name='pa_web_session_end_idx')],
                'unique_together': {('agent', 'user')},
            },
        ),
    ]
