Files
Iliyan Angelov 6b247e5b9f Updates
2025-09-19 11:58:53 +03:00

231 lines
18 KiB
Python

# Generated by Django 5.2.6 on 2025-09-18 15:08
import django.core.validators
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='Incident',
fields=[
('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('title', models.CharField(max_length=200)),
('description', models.TextField()),
('free_text', models.TextField(help_text='Original free text description from user')),
('category', models.CharField(blank=True, max_length=100, null=True)),
('subcategory', models.CharField(blank=True, max_length=100, null=True)),
('classification_confidence', models.FloatField(blank=True, help_text='AI confidence score for classification (0.0-1.0)', null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('severity', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical'), ('EMERGENCY', 'Emergency')], default='MEDIUM', max_length=20)),
('suggested_severity', models.CharField(blank=True, choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical'), ('EMERGENCY', 'Emergency')], max_length=20, null=True)),
('severity_confidence', models.FloatField(blank=True, help_text='AI confidence score for severity suggestion (0.0-1.0)', null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('priority', models.CharField(choices=[('P1', 'P1 - Critical'), ('P2', 'P2 - High'), ('P3', 'P3 - Medium'), ('P4', 'P4 - Low')], default='P3', max_length=10)),
('status', models.CharField(choices=[('OPEN', 'Open'), ('IN_PROGRESS', 'In Progress'), ('RESOLVED', 'Resolved'), ('CLOSED', 'Closed'), ('CANCELLED', 'Cancelled')], default='OPEN', max_length=20)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('resolved_at', models.DateTimeField(blank=True, null=True)),
('affected_users', models.PositiveIntegerField(default=0)),
('business_impact', models.TextField(blank=True, null=True)),
('estimated_downtime', models.DurationField(blank=True, null=True)),
('ai_processed', models.BooleanField(default=False)),
('ai_processing_error', models.TextField(blank=True, null=True)),
('last_ai_analysis', models.DateTimeField(blank=True, null=True)),
('is_duplicate', models.BooleanField(default=False)),
('duplicate_confidence', models.FloatField(blank=True, help_text='AI confidence score for duplication detection (0.0-1.0)', null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
('original_incident', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='duplicates', to='incident_intelligence.incident')),
('reporter', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reported_incidents', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_at'],
},
),
migrations.CreateModel(
name='DuplicationDetection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('duplication_type', models.CharField(choices=[('EXACT', 'Exact Duplicate'), ('NEAR_DUPLICATE', 'Near Duplicate'), ('SIMILAR', 'Similar Incident'), ('POTENTIAL_DUPLICATE', 'Potential Duplicate')], max_length=20)),
('similarity_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('confidence_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('text_similarity', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('temporal_proximity', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('service_similarity', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('recommended_action', models.CharField(choices=[('MERGE', 'Merge Incidents'), ('LINK', 'Link Incidents'), ('REVIEW', 'Manual Review'), ('NO_ACTION', 'No Action')], max_length=20)),
('merge_confidence', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('reasoning', models.TextField(help_text='AI explanation for duplication detection')),
('shared_elements', models.JSONField(default=list, help_text='Elements shared between incidents')),
('status', models.CharField(choices=[('DETECTED', 'Detected'), ('REVIEWED', 'Reviewed'), ('MERGED', 'Merged'), ('REJECTED', 'Rejected')], default='DETECTED', max_length=20)),
('created_at', models.DateTimeField(auto_now_add=True)),
('reviewed_at', models.DateTimeField(blank=True, null=True)),
('model_version', models.CharField(default='v1.0', max_length=50)),
('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
('incident_a', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='duplication_as_a', to='incident_intelligence.incident')),
('incident_b', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='duplication_as_b', to='incident_intelligence.incident')),
],
),
migrations.CreateModel(
name='AIProcessingLog',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('processing_type', models.CharField(choices=[('CLASSIFICATION', 'Classification'), ('SEVERITY_ANALYSIS', 'Severity Analysis'), ('CORRELATION', 'Correlation Analysis'), ('DUPLICATION_DETECTION', 'Duplication Detection'), ('PATTERN_DETECTION', 'Pattern Detection')], max_length=30)),
('status', models.CharField(choices=[('PENDING', 'Pending'), ('PROCESSING', 'Processing'), ('COMPLETED', 'Completed'), ('FAILED', 'Failed'), ('SKIPPED', 'Skipped')], default='PENDING', max_length=20)),
('related_incidents', models.JSONField(default=list, help_text='List of related incident IDs')),
('input_data', models.JSONField(help_text='Input data for processing')),
('output_data', models.JSONField(blank=True, help_text='Output data from processing', null=True)),
('error_message', models.TextField(blank=True, null=True)),
('processing_time', models.FloatField(blank=True, help_text='Processing time in seconds', null=True)),
('model_version', models.CharField(default='v1.0', max_length=50)),
('confidence_score', models.FloatField(blank=True, null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('started_at', models.DateTimeField(auto_now_add=True)),
('completed_at', models.DateTimeField(blank=True, null=True)),
('incident', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='incident_intelligence.incident')),
],
options={
'ordering': ['-started_at'],
},
),
migrations.CreateModel(
name='IncidentClassification',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('predicted_category', models.CharField(max_length=100)),
('predicted_subcategory', models.CharField(max_length=100)),
('confidence_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('alternative_categories', models.JSONField(default=list, help_text='List of alternative category predictions')),
('extracted_keywords', models.JSONField(default=list, help_text='Keywords extracted from incident text')),
('sentiment_score', models.FloatField(blank=True, help_text='Sentiment analysis score (-1 to 1)', null=True)),
('urgency_indicators', models.JSONField(default=list, help_text='Detected urgency indicators')),
('model_version', models.CharField(default='v1.0', max_length=50)),
('processing_time', models.FloatField(help_text='Time taken for classification in seconds')),
('created_at', models.DateTimeField(auto_now_add=True)),
('incident', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='ai_classification', to='incident_intelligence.incident')),
],
),
migrations.CreateModel(
name='IncidentCorrelation',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('correlation_type', models.CharField(choices=[('SAME_SERVICE', 'Same Service'), ('SAME_COMPONENT', 'Same Component'), ('TEMPORAL', 'Temporal Correlation'), ('PATTERN', 'Pattern Match'), ('DEPENDENCY', 'Dependency Related'), ('CASCADE', 'Cascade Effect')], max_length=20)),
('confidence_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('correlation_strength', models.CharField(choices=[('WEAK', 'Weak'), ('MODERATE', 'Moderate'), ('STRONG', 'Strong'), ('VERY_STRONG', 'Very Strong')], max_length=20)),
('shared_keywords', models.JSONField(default=list, help_text='Keywords shared between incidents')),
('time_difference', models.DurationField(help_text='Time difference between incidents')),
('similarity_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('is_problem_indicator', models.BooleanField(default=False, help_text='Indicates if this correlation suggests a larger problem')),
('problem_description', models.TextField(blank=True, null=True)),
('created_at', models.DateTimeField(auto_now_add=True)),
('model_version', models.CharField(default='v1.0', max_length=50)),
('primary_incident', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='correlations_as_primary', to='incident_intelligence.incident')),
('related_incident', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='correlations_as_related', to='incident_intelligence.incident')),
],
),
migrations.CreateModel(
name='IncidentPattern',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('pattern_type', models.CharField(choices=[('RECURRING', 'Recurring Issue'), ('SEASONAL', 'Seasonal Pattern'), ('TREND', 'Trend Analysis'), ('ANOMALY', 'Anomaly Detection')], max_length=20)),
('description', models.TextField()),
('frequency', models.CharField(help_text='How often this pattern occurs', max_length=50)),
('affected_services', models.JSONField(default=list, help_text='Services affected by this pattern')),
('common_keywords', models.JSONField(default=list, help_text='Common keywords in incidents with this pattern')),
('incident_count', models.PositiveIntegerField(default=0)),
('confidence_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('last_occurrence', models.DateTimeField(blank=True, null=True)),
('next_predicted_occurrence', models.DateTimeField(blank=True, null=True)),
('is_active', models.BooleanField(default=True)),
('is_resolved', models.BooleanField(default=False)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('model_version', models.CharField(default='v1.0', max_length=50)),
('incidents', models.ManyToManyField(related_name='patterns', to='incident_intelligence.incident')),
],
options={
'ordering': ['-confidence_score', '-incident_count'],
},
),
migrations.CreateModel(
name='SeveritySuggestion',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('suggested_severity', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical'), ('EMERGENCY', 'Emergency')], max_length=20)),
('confidence_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('user_impact_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('business_impact_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('technical_impact_score', models.FloatField(validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(1.0)])),
('reasoning', models.TextField(help_text='AI explanation for severity suggestion')),
('impact_factors', models.JSONField(default=list, help_text='List of factors that influenced the severity')),
('model_version', models.CharField(default='v1.0', max_length=50)),
('processing_time', models.FloatField(help_text='Time taken for severity analysis in seconds')),
('created_at', models.DateTimeField(auto_now_add=True)),
('incident', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='severity_suggestion', to='incident_intelligence.incident')),
],
),
migrations.AddIndex(
model_name='incident',
index=models.Index(fields=['status', 'severity'], name='incident_in_status_69cd1f_idx'),
),
migrations.AddIndex(
model_name='incident',
index=models.Index(fields=['category', 'subcategory'], name='incident_in_categor_b1397a_idx'),
),
migrations.AddIndex(
model_name='incident',
index=models.Index(fields=['created_at'], name='incident_in_created_95a890_idx'),
),
migrations.AddIndex(
model_name='incident',
index=models.Index(fields=['assigned_to'], name='incident_in_assigne_a00121_idx'),
),
migrations.AddIndex(
model_name='duplicationdetection',
index=models.Index(fields=['duplication_type', 'confidence_score'], name='incident_in_duplica_170e8c_idx'),
),
migrations.AddIndex(
model_name='duplicationdetection',
index=models.Index(fields=['status'], name='incident_in_status_d1db68_idx'),
),
migrations.AlterUniqueTogether(
name='duplicationdetection',
unique_together={('incident_a', 'incident_b')},
),
migrations.AddIndex(
model_name='aiprocessinglog',
index=models.Index(fields=['processing_type', 'status'], name='incident_in_process_3b7238_idx'),
),
migrations.AddIndex(
model_name='aiprocessinglog',
index=models.Index(fields=['incident', 'processing_type'], name='incident_in_inciden_ef07e9_idx'),
),
migrations.AddIndex(
model_name='incidentcorrelation',
index=models.Index(fields=['correlation_type', 'confidence_score'], name='incident_in_correla_a6263a_idx'),
),
migrations.AddIndex(
model_name='incidentcorrelation',
index=models.Index(fields=['is_problem_indicator'], name='incident_in_is_prob_746ecd_idx'),
),
migrations.AlterUniqueTogether(
name='incidentcorrelation',
unique_together={('primary_incident', 'related_incident')},
),
migrations.AddIndex(
model_name='incidentpattern',
index=models.Index(fields=['pattern_type', 'is_active'], name='incident_in_pattern_336ec0_idx'),
),
migrations.AddIndex(
model_name='incidentpattern',
index=models.Index(fields=['confidence_score'], name='incident_in_confide_d39236_idx'),
),
]