# Generated by Django 5.0.6 on 2025-08-26 08:33

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


class Migration(migrations.Migration):

    dependencies = [
        ('stiftung', '0014_dokumentlink_rentmeister_id'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='BackupJob',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('backup_type', models.CharField(choices=[('full', 'Vollständiges Backup'), ('database', 'Nur Datenbank'), ('files', 'Nur Dateien')], max_length=20, verbose_name='Backup-Typ')),
                ('status', models.CharField(choices=[('pending', 'Wartend'), ('running', 'Läuft'), ('completed', 'Abgeschlossen'), ('failed', 'Fehlgeschlagen')], default='pending', max_length=20, verbose_name='Status')),
                ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Erstellt am')),
                ('started_at', models.DateTimeField(blank=True, null=True, verbose_name='Gestartet am')),
                ('completed_at', models.DateTimeField(blank=True, null=True, verbose_name='Abgeschlossen am')),
                ('backup_filename', models.CharField(blank=True, max_length=255, verbose_name='Backup-Dateiname')),
                ('backup_size', models.BigIntegerField(blank=True, null=True, verbose_name='Backup-Größe (Bytes)')),
                ('error_message', models.TextField(blank=True, verbose_name='Fehlermeldung')),
                ('database_size', models.BigIntegerField(blank=True, null=True, verbose_name='Datenbankgröße (Bytes)')),
                ('files_count', models.IntegerField(blank=True, null=True, verbose_name='Anzahl Dateien')),
                ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Erstellt von')),
            ],
            options={
                'verbose_name': 'Backup-Job',
                'verbose_name_plural': 'Backup-Jobs',
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='AuditLog',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('username', models.CharField(max_length=150, verbose_name='Benutzername')),
                ('timestamp', models.DateTimeField(auto_now_add=True, verbose_name='Zeitpunkt')),
                ('action', models.CharField(choices=[('create', 'Erstellt'), ('update', 'Aktualisiert'), ('delete', 'Gelöscht'), ('link', 'Verknüpft'), ('unlink', 'Verknüpfung entfernt'), ('login', 'Anmeldung'), ('logout', 'Abmeldung'), ('backup', 'Backup erstellt'), ('restore', 'Wiederherstellung'), ('export', 'Export'), ('import', 'Import')], max_length=20, verbose_name='Aktion')),
                ('entity_type', models.CharField(choices=[('destinataer', 'Destinatär'), ('land', 'Länderei'), ('paechter', 'Pächter'), ('verpachtung', 'Verpachtung'), ('foerderung', 'Förderung'), ('rentmeister', 'Rentmeister'), ('stiftungskonto', 'Stiftungskonto'), ('verwaltungskosten', 'Verwaltungskosten'), ('banktransaction', 'Bank-Transaktion'), ('dokumentlink', 'Dokument-Verknüpfung'), ('system', 'System'), ('user', 'Benutzer')], max_length=20, verbose_name='Entitätstyp')),
                ('entity_id', models.CharField(blank=True, max_length=100, verbose_name='Entitäts-ID')),
                ('entity_name', models.CharField(max_length=255, verbose_name='Entitätsname')),
                ('description', models.TextField(verbose_name='Beschreibung')),
                ('changes', models.JSONField(blank=True, null=True, verbose_name='Änderungen')),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True, verbose_name='IP-Adresse')),
                ('user_agent', models.TextField(blank=True, verbose_name='User Agent')),
                ('session_key', models.CharField(blank=True, max_length=40, verbose_name='Session-Key')),
                ('user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL, verbose_name='Benutzer')),
            ],
            options={
                'verbose_name': 'Audit Log Eintrag',
                'verbose_name_plural': 'Audit Log Einträge',
                'ordering': ['-timestamp'],
                'indexes': [models.Index(fields=['timestamp'], name='stiftung_au_timesta_c4591e_idx'), models.Index(fields=['user', 'timestamp'], name='stiftung_au_user_id_e3fc12_idx'), models.Index(fields=['entity_type', 'timestamp'], name='stiftung_au_entity__68f25d_idx'), models.Index(fields=['action', 'timestamp'], name='stiftung_au_action_288765_idx')],
            },
        ),
    ]
