# Generated by Django 5.2.6 on 2025-09-16 10:45

import django.db.models.deletion
import django.utils.timezone
import uuid
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='RequestProfile',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('timestamp', models.DateTimeField(db_index=True, default=django.utils.timezone.now)),
                ('url', models.URLField(max_length=2000)),
                ('view_name', models.CharField(blank=True, max_length=200)),
                ('method', models.CharField(max_length=10)),
                ('duration', models.FloatField(help_text='Total request duration in seconds')),
                ('memory_usage', models.FloatField(blank=True, help_text='Peak memory usage in MB', null=True)),
                ('cpu_usage', models.FloatField(blank=True, help_text='CPU usage percentage', null=True)),
                ('db_queries_count', models.IntegerField(default=0)),
                ('db_queries_time', models.FloatField(default=0.0, help_text='Total DB query time in seconds')),
                ('status_code', models.IntegerField()),
                ('is_error', models.BooleanField(default=False)),
                ('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-timestamp'],
            },
        ),
        migrations.CreateModel(
            name='MemoryProfile',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('peak_memory_mb', models.FloatField()),
                ('memory_report_path', models.CharField(blank=True, max_length=500)),
                ('heap_size', models.FloatField(blank=True, null=True)),
                ('allocated_objects', models.IntegerField(blank=True, null=True)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('request_profile', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='memory_profile', to='django_profileboard.requestprofile')),
            ],
        ),
        migrations.CreateModel(
            name='ExternalAPICall',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('url', models.URLField()),
                ('method', models.CharField(max_length=10)),
                ('duration', models.FloatField()),
                ('status_code', models.IntegerField()),
                ('trace_id', models.CharField(blank=True, max_length=32)),
                ('span_id', models.CharField(blank=True, max_length=16)),
                ('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
                ('request_profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='api_calls', to='django_profileboard.requestprofile')),
            ],
            options={
                'ordering': ['timestamp'],
            },
        ),
        migrations.CreateModel(
            name='DatabaseQuery',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('sql', models.TextField()),
                ('params', models.JSONField(default=dict)),
                ('duration', models.FloatField(help_text='Query duration in seconds')),
                ('stack_trace', models.TextField(blank=True)),
                ('is_duplicate', models.BooleanField(default=False)),
                ('is_similar', models.BooleanField(default=False)),
                ('similar_query_hash', models.CharField(blank=True, db_index=True, max_length=64)),
                ('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
                ('request_profile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='database_queries', to='django_profileboard.requestprofile')),
            ],
            options={
                'ordering': ['timestamp'],
            },
        ),
        migrations.AddIndex(
            model_name='requestprofile',
            index=models.Index(fields=['timestamp', 'view_name'], name='django_prof_timesta_028dc9_idx'),
        ),
        migrations.AddIndex(
            model_name='requestprofile',
            index=models.Index(fields=['duration'], name='django_prof_duratio_ad050f_idx'),
        ),
        migrations.AddIndex(
            model_name='requestprofile',
            index=models.Index(fields=['db_queries_count'], name='django_prof_db_quer_08c1cc_idx'),
        ),
    ]
