# Generated by Django 4.2.29 on 2026-03-27 17:50

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


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('django_eds_auth', '0002_alter_failedauthenticationattempt_attempt_type'),
    ]

    operations = [
        migrations.CreateModel(
            name='SecurityLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('event_time', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('ip_address', models.GenericIPAddressField(blank=True, db_index=True, null=True)),
                ('event_type', models.CharField(choices=[('auth_success', 'Successful authentication'), ('auth_failure', 'Authentication failure'), ('eds_validation_error', 'EDS validation error'), ('rate_limit_locked', 'Rate limit lockout'), ('backend_error', 'Authentication backend error')], db_index=True, max_length=50)),
                ('details', models.JSONField(blank=True, default=dict)),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='security_logs', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Security Log',
                'verbose_name_plural': 'Security Logs',
                'ordering': ['-event_time'],
                'indexes': [models.Index(fields=['event_type', '-event_time'], name='django_eds__event_t_6f816e_idx'), models.Index(fields=['ip_address', '-event_time'], name='django_eds__ip_addr_a20af2_idx'), models.Index(fields=['user', '-event_time'], name='django_eds__user_id_f8fa15_idx')],
            },
        ),
    ]
