# Generated by Django 5.0.7 on 2025-12-14 09:11

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('contenttypes', '0002_remove_content_type_name'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='ActionLog',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('object_id', models.PositiveIntegerField(verbose_name='ID objet')),
                ('object_repr', models.CharField(blank=True, max_length=255, verbose_name='Représentation objet')),
                ('action', models.CharField(choices=[('CREATE', 'Création'), ('UPDATE', 'Modification'), ('DELETE', 'Suppression')], max_length=10, verbose_name='Action')),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True, verbose_name='Adresse IP')),
                ('user_agent', models.TextField(blank=True, verbose_name='User-Agent')),
                ('changes', models.JSONField(default=dict, verbose_name='Modifications')),
                ('timestamp', models.DateTimeField(auto_now_add=True, db_index=True, verbose_name='Date/Heure')),
                ('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', verbose_name='Type de contenu')),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='action_logs', to=settings.AUTH_USER_MODEL, verbose_name='Utilisateur')),
            ],
            options={
                'verbose_name': "Journal d'action",
                'verbose_name_plural': 'Journal des actions',
                'ordering': ['-timestamp'],
                'indexes': [models.Index(fields=['content_type', 'object_id'], name='history_act_content_14194b_idx'), models.Index(fields=['user', 'timestamp'], name='history_act_user_id_ca8939_idx'), models.Index(fields=['action', 'timestamp'], name='history_act_action_a84aa4_idx')],
            },
        ),
    ]
