feat: add stage 0 foundation
This commit is contained in:
61
backend/apps/audit/migrations/0001_initial.py
Normal file
61
backend/apps/audit/migrations/0001_initial.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# Generated by Django 5.2.15 on 2026-06-30 07:47
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='OperationAuditLog',
|
||||
fields=[
|
||||
(
|
||||
'id',
|
||||
models.BigAutoField(
|
||||
auto_created=True,
|
||||
primary_key=True,
|
||||
serialize=False,
|
||||
verbose_name='ID',
|
||||
),
|
||||
),
|
||||
('module', models.CharField(max_length=80)),
|
||||
('action', models.CharField(max_length=80)),
|
||||
('target_type', models.CharField(max_length=80)),
|
||||
('target_id', models.CharField(blank=True, max_length=120)),
|
||||
('request_snapshot', models.JSONField(blank=True, default=dict)),
|
||||
('result', models.CharField(max_length=20)),
|
||||
('ip_address', models.GenericIPAddressField(blank=True, null=True)),
|
||||
('user_agent', models.TextField(blank=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
(
|
||||
'user',
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.SET_NULL,
|
||||
related_name='operation_audit_logs',
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
],
|
||||
options={
|
||||
'ordering': ['-created_at'],
|
||||
'indexes': [
|
||||
models.Index(fields=['module', 'action'], name='audit_opera_module_8f87af_idx'),
|
||||
models.Index(
|
||||
fields=['target_type', 'target_id'],
|
||||
name='audit_opera_target__560d76_idx',
|
||||
),
|
||||
models.Index(fields=['created_at'], name='audit_opera_created_077b40_idx'),
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user