# Generated by Django 4.2.15 on 2026-03-05 05:39

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='OperationLog',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False)),
                ('trace_id', models.CharField(db_index=True, help_text='全链路唯一ID', max_length=32)),
                ('parent_id', models.CharField(blank=True, help_text='父级操作ID', max_length=32, null=True)),
                ('operation_type', models.CharField(choices=[('startup', '系统启动'), ('request', 'HTTP请求'), ('view', '视图处理'), ('db', '数据库操作'), ('cache', '缓存操作'), ('celery', '异步任务'), ('command', '管理命令'), ('signal', '信号处理'), ('auth', '认证授权'), ('exception', '异常错误'), ('custom', '自定义业务')], db_index=True, max_length=20)),
                ('level', models.CharField(default='INFO', max_length=10)),
                ('start_time', models.DateTimeField(db_index=True)),
                ('end_time', models.DateTimeField(blank=True, null=True)),
                ('duration', models.FloatField(help_text='耗时(ms)', null=True)),
                ('user_id', models.CharField(blank=True, db_index=True, max_length=64, null=True)),
                ('username', models.CharField(blank=True, max_length=150, null=True)),
                ('ip_address', models.GenericIPAddressField(blank=True, null=True)),
                ('details', models.JSONField(default=dict)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
            ],
            options={
                'verbose_name': '操作日志',
                'verbose_name_plural': '操作日志',
                'ordering': ['-created_at'],
                'indexes': [models.Index(fields=['operation_type', 'created_at'], name='django_ops__operati_909937_idx'), models.Index(fields=['user_id', 'created_at'], name='django_ops__user_id_dd10fb_idx')],
            },
        ),
    ]
