# Generated by Django 5.2.6 on 2025-09-18 19:44 import django.db.models.deletion 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='MonitoringTarget', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=200, unique=True)), ('description', models.TextField()), ('target_type', models.CharField(choices=[('APPLICATION', 'Application'), ('DATABASE', 'Database'), ('CACHE', 'Cache'), ('QUEUE', 'Message Queue'), ('EXTERNAL_API', 'External API'), ('SERVICE', 'Internal Service'), ('INFRASTRUCTURE', 'Infrastructure'), ('MODULE', 'Django Module')], max_length=20)), ('endpoint_url', models.URLField(blank=True, null=True)), ('connection_config', models.JSONField(default=dict, help_text='Connection configuration (credentials, timeouts, etc.)')), ('check_interval_seconds', models.PositiveIntegerField(default=60)), ('timeout_seconds', models.PositiveIntegerField(default=30)), ('retry_count', models.PositiveIntegerField(default=3)), ('health_check_enabled', models.BooleanField(default=True)), ('health_check_endpoint', models.CharField(blank=True, max_length=200, null=True)), ('expected_status_codes', models.JSONField(default=list, help_text='Expected HTTP status codes for health checks')), ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('INACTIVE', 'Inactive'), ('MAINTENANCE', 'Maintenance'), ('ERROR', 'Error')], default='ACTIVE', max_length=20)), ('last_checked', models.DateTimeField(blank=True, null=True)), ('last_status', models.CharField(choices=[('HEALTHY', 'Healthy'), ('WARNING', 'Warning'), ('CRITICAL', 'Critical'), ('UNKNOWN', 'Unknown')], default='UNKNOWN', max_length=20)), ('related_module', models.CharField(blank=True, help_text="Related Django module (e.g., 'security', 'incident_intelligence')", max_length=50, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name'], }, ), migrations.CreateModel( name='HealthCheck', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('check_type', models.CharField(choices=[('HTTP', 'HTTP Health Check'), ('DATABASE', 'Database Connection'), ('CACHE', 'Cache Connection'), ('QUEUE', 'Message Queue'), ('CUSTOM', 'Custom Check'), ('PING', 'Network Ping'), ('SSL', 'SSL Certificate')], max_length=20)), ('status', models.CharField(choices=[('HEALTHY', 'Healthy'), ('WARNING', 'Warning'), ('CRITICAL', 'Critical'), ('UNKNOWN', 'Unknown')], max_length=20)), ('response_time_ms', models.PositiveIntegerField(blank=True, null=True)), ('status_code', models.PositiveIntegerField(blank=True, null=True)), ('response_body', models.TextField(blank=True, null=True)), ('error_message', models.TextField(blank=True, null=True)), ('cpu_usage_percent', models.FloatField(blank=True, null=True)), ('memory_usage_percent', models.FloatField(blank=True, null=True)), ('disk_usage_percent', models.FloatField(blank=True, null=True)), ('checked_at', models.DateTimeField(auto_now_add=True)), ('target', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='health_checks', to='monitoring.monitoringtarget')), ], options={ 'ordering': ['-checked_at'], }, ), migrations.CreateModel( name='SystemMetric', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=200)), ('description', models.TextField()), ('metric_type', models.CharField(choices=[('PERFORMANCE', 'Performance Metric'), ('BUSINESS', 'Business Metric'), ('SECURITY', 'Security Metric'), ('INFRASTRUCTURE', 'Infrastructure Metric'), ('CUSTOM', 'Custom Metric')], max_length=20)), ('category', models.CharField(choices=[('API_RESPONSE_TIME', 'API Response Time'), ('THROUGHPUT', 'Throughput'), ('ERROR_RATE', 'Error Rate'), ('AVAILABILITY', 'Availability'), ('INCIDENT_COUNT', 'Incident Count'), ('MTTR', 'Mean Time to Resolve'), ('MTTA', 'Mean Time to Acknowledge'), ('SLA_COMPLIANCE', 'SLA Compliance'), ('SECURITY_EVENTS', 'Security Events'), ('AUTOMATION_SUCCESS', 'Automation Success Rate'), ('AI_ACCURACY', 'AI Model Accuracy'), ('COST_IMPACT', 'Cost Impact'), ('USER_ACTIVITY', 'User Activity'), ('SYSTEM_RESOURCES', 'System Resources')], max_length=30)), ('unit', models.CharField(help_text='Unit of measurement', max_length=50)), ('aggregation_method', models.CharField(choices=[('AVERAGE', 'Average'), ('SUM', 'Sum'), ('COUNT', 'Count'), ('MIN', 'Minimum'), ('MAX', 'Maximum'), ('PERCENTILE_95', '95th Percentile'), ('PERCENTILE_99', '99th Percentile')], max_length=20)), ('collection_interval_seconds', models.PositiveIntegerField(default=300)), ('retention_days', models.PositiveIntegerField(default=90)), ('warning_threshold', models.FloatField(blank=True, null=True)), ('critical_threshold', models.FloatField(blank=True, null=True)), ('is_active', models.BooleanField(default=True)), ('is_system_metric', models.BooleanField(default=False)), ('related_module', models.CharField(blank=True, help_text='Related Django module', max_length=50, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name'], }, ), migrations.CreateModel( name='MetricMeasurement', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('value', models.DecimalField(decimal_places=4, max_digits=15)), ('timestamp', models.DateTimeField(auto_now_add=True)), ('tags', models.JSONField(default=dict, help_text='Additional tags for this measurement')), ('metadata', models.JSONField(default=dict, help_text='Additional metadata')), ('metric', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='measurements', to='monitoring.systemmetric')), ], options={ 'ordering': ['-timestamp'], }, ), migrations.CreateModel( name='AlertRule', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=200)), ('description', models.TextField()), ('alert_type', models.CharField(choices=[('THRESHOLD', 'Threshold Alert'), ('ANOMALY', 'Anomaly Alert'), ('PATTERN', 'Pattern Alert'), ('AVAILABILITY', 'Availability Alert'), ('PERFORMANCE', 'Performance Alert')], max_length=20)), ('severity', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical')], max_length=20)), ('condition', models.JSONField(help_text='Alert condition configuration')), ('evaluation_interval_seconds', models.PositiveIntegerField(default=60)), ('notification_channels', models.JSONField(default=list, help_text='List of notification channels (email, slack, webhook, etc.)')), ('notification_template', models.TextField(blank=True, help_text='Custom notification template', null=True)), ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('INACTIVE', 'Inactive'), ('MAINTENANCE', 'Maintenance')], default='ACTIVE', max_length=20)), ('is_enabled', models.BooleanField(default=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ('target', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='alert_rules', to='monitoring.monitoringtarget')), ('metric', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='alert_rules', to='monitoring.systemmetric')), ], options={ 'ordering': ['name'], }, ), migrations.CreateModel( name='SystemStatus', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('status', models.CharField(choices=[('OPERATIONAL', 'Operational'), ('DEGRADED', 'Degraded'), ('PARTIAL_OUTAGE', 'Partial Outage'), ('MAJOR_OUTAGE', 'Major Outage'), ('MAINTENANCE', 'Maintenance')], max_length=20)), ('message', models.TextField(help_text='Status message for users')), ('affected_services', models.JSONField(default=list, help_text='List of affected services')), ('estimated_resolution', models.DateTimeField(blank=True, null=True)), ('started_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('resolved_at', models.DateTimeField(blank=True, null=True)), ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['-started_at'], }, ), migrations.CreateModel( name='Alert', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=200)), ('description', models.TextField()), ('severity', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical')], max_length=20)), ('status', models.CharField(choices=[('TRIGGERED', 'Triggered'), ('ACKNOWLEDGED', 'Acknowledged'), ('RESOLVED', 'Resolved'), ('SUPPRESSED', 'Suppressed')], default='TRIGGERED', max_length=20)), ('triggered_value', models.DecimalField(blank=True, decimal_places=4, max_digits=15, null=True)), ('threshold_value', models.DecimalField(blank=True, decimal_places=4, max_digits=15, null=True)), ('context_data', models.JSONField(default=dict, help_text='Additional context data for the alert')), ('triggered_at', models.DateTimeField(auto_now_add=True)), ('acknowledged_at', models.DateTimeField(blank=True, null=True)), ('resolved_at', models.DateTimeField(blank=True, null=True)), ('acknowledged_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='acknowledged_alerts', to=settings.AUTH_USER_MODEL)), ('resolved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='resolved_alerts', to=settings.AUTH_USER_MODEL)), ('rule', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='alerts', to='monitoring.alertrule')), ], options={ 'ordering': ['-triggered_at'], 'indexes': [models.Index(fields=['rule', 'status'], name='monitoring__rule_id_0ff7d3_idx'), models.Index(fields=['severity', 'status'], name='monitoring__severit_1e6a2c_idx'), models.Index(fields=['triggered_at'], name='monitoring__trigger_743dcf_idx')], }, ), migrations.CreateModel( name='MonitoringDashboard', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=200)), ('description', models.TextField()), ('dashboard_type', models.CharField(choices=[('SYSTEM_OVERVIEW', 'System Overview'), ('PERFORMANCE', 'Performance'), ('BUSINESS_METRICS', 'Business Metrics'), ('SECURITY', 'Security'), ('INFRASTRUCTURE', 'Infrastructure'), ('CUSTOM', 'Custom')], max_length=20)), ('layout_config', models.JSONField(default=dict, help_text='Dashboard layout configuration')), ('widget_configs', models.JSONField(default=list, help_text='Configuration for dashboard widgets')), ('is_public', models.BooleanField(default=False)), ('allowed_roles', models.JSONField(default=list, help_text='List of roles that can access this dashboard')), ('auto_refresh_enabled', models.BooleanField(default=True)), ('refresh_interval_seconds', models.PositiveIntegerField(default=30)), ('is_active', models.BooleanField(default=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('allowed_users', models.ManyToManyField(blank=True, related_name='accessible_monitoring_dashboards', to=settings.AUTH_USER_MODEL)), ('created_by', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name'], 'indexes': [models.Index(fields=['dashboard_type', 'is_active'], name='monitoring__dashboa_2e7a27_idx'), models.Index(fields=['is_public'], name='monitoring__is_publ_811f62_idx')], }, ), migrations.AddIndex( model_name='monitoringtarget', index=models.Index(fields=['target_type', 'status'], name='monitoring__target__f37347_idx'), ), migrations.AddIndex( model_name='monitoringtarget', index=models.Index(fields=['related_module'], name='monitoring__related_0c51fc_idx'), ), migrations.AddIndex( model_name='monitoringtarget', index=models.Index(fields=['last_checked'], name='monitoring__last_ch_83ce18_idx'), ), migrations.AddIndex( model_name='healthcheck', index=models.Index(fields=['target', 'checked_at'], name='monitoring__target__8d1cd6_idx'), ), migrations.AddIndex( model_name='healthcheck', index=models.Index(fields=['status', 'checked_at'], name='monitoring__status_636b2b_idx'), ), migrations.AddIndex( model_name='healthcheck', index=models.Index(fields=['check_type'], name='monitoring__check_t_b442f3_idx'), ), migrations.AddIndex( model_name='systemmetric', index=models.Index(fields=['metric_type', 'category'], name='monitoring__metric__df4606_idx'), ), migrations.AddIndex( model_name='systemmetric', index=models.Index(fields=['related_module'], name='monitoring__related_7b383b_idx'), ), migrations.AddIndex( model_name='systemmetric', index=models.Index(fields=['is_active'], name='monitoring__is_acti_c90676_idx'), ), migrations.AddIndex( model_name='metricmeasurement', index=models.Index(fields=['metric', 'timestamp'], name='monitoring__metric__216cac_idx'), ), migrations.AddIndex( model_name='metricmeasurement', index=models.Index(fields=['timestamp'], name='monitoring__timesta_75a739_idx'), ), migrations.AddIndex( model_name='alertrule', index=models.Index(fields=['alert_type', 'severity'], name='monitoring__alert_t_915b15_idx'), ), migrations.AddIndex( model_name='alertrule', index=models.Index(fields=['status', 'is_enabled'], name='monitoring__status_e905cc_idx'), ), migrations.AddIndex( model_name='systemstatus', index=models.Index(fields=['status', 'started_at'], name='monitoring__status_18966f_idx'), ), migrations.AddIndex( model_name='systemstatus', index=models.Index(fields=['started_at'], name='monitoring__started_d85786_idx'), ), ]