Updates
This commit is contained in:
230
ETB-API/incident_intelligence/migrations/0001_initial.py
Normal file
230
ETB-API/incident_intelligence/migrations/0001_initial.py
Normal file
@@ -0,0 +1,230 @@
|
||||
# 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'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 5.2.6 on 2025-09-18 15:16
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('incident_intelligence', '0001_initial'),
|
||||
('security', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='data_classification',
|
||||
field=models.ForeignKey(blank=True, help_text='Data classification level for this incident', null=True, on_delete=django.db.models.deletion.SET_NULL, to='security.dataclassification'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='is_sensitive',
|
||||
field=models.BooleanField(default=False, help_text='Whether this incident contains sensitive information'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='security_clearance_required',
|
||||
field=models.BooleanField(default=False, help_text='Whether this incident requires special security clearance'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 5.2.6 on 2025-09-18 15:29
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('incident_intelligence', '0002_incident_data_classification_incident_is_sensitive_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='auto_remediation_attempted',
|
||||
field=models.BooleanField(default=False, help_text='Whether auto-remediation has been attempted'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='automation_enabled',
|
||||
field=models.BooleanField(default=True, help_text='Whether automation can be triggered for this incident'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='maintenance_window_override',
|
||||
field=models.BooleanField(default=False, help_text='Whether this incident should override maintenance window suppressions'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='runbook_suggested',
|
||||
field=models.BooleanField(default=False, help_text='Whether a runbook has been suggested for this incident'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,30 @@
|
||||
# Generated by Django 5.2.6 on 2025-09-18 15:51
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('incident_intelligence', '0003_incident_auto_remediation_attempted_and_more'),
|
||||
('sla_oncall', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='oncall_assignment',
|
||||
field=models.ForeignKey(blank=True, help_text='On-call assignment responsible for this incident', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='assigned_incidents', to='sla_oncall.oncallassignment'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='sla_override',
|
||||
field=models.BooleanField(default=False, help_text='Whether this incident overrides normal SLA calculations'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='incident',
|
||||
name='sla_override_reason',
|
||||
field=models.TextField(blank=True, help_text='Reason for SLA override', null=True),
|
||||
),
|
||||
]
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user