# Generated by Django 4.2.5 on 2025-09-08 17:00

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
    ]

    operations = [
        migrations.CreateModel(
            name='AuditLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField()),
                ('action', models.CharField(choices=[('CREATE', 'Creado'), ('UPDATE', 'Modificado'), ('DELETE', 'Eliminado'), ('READ', 'Consultado')], default='UPDATE', max_length=10)),
                ('level', models.CharField(choices=[('LOW', 'Bajo'), ('MEDIUM', 'Medio'), ('HIGH', 'Alto'), ('CRITICAL', 'Crítico')], default='MEDIUM', max_length=10)),
                ('changes', models.JSONField(blank=True, default=dict)),
                ('user_id', models.PositiveIntegerField(blank=True, null=True)),
                ('username', models.CharField(default='anonymous', max_length=150)),
                ('user_email', models.EmailField(blank=True, max_length=254, null=True)),
                ('metadata', models.JSONField(blank=True, default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype')),
            ],
            options={
                'verbose_name': 'Log de Auditoría',
                'verbose_name_plural': 'Logs de Auditoría',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['content_type', 'object_id'], name='django_trac_content_da99c1_idx'), models.Index(fields=['action', 'created_at'], name='django_trac_action_a4b681_idx'), models.Index(fields=['user_id', 'created_at'], name='django_trac_user_id_31993e_idx'), models.Index(fields=['level', 'created_at'], name='django_trac_level_b36c85_idx')],
            },
        ),
    ]
