# Generated by Django 5.2.6 on 2025-09-18 16:41 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 = [ ('incident_intelligence', '0004_incident_oncall_assignment_incident_sla_override_and_more'), migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='RegulatoryFramework', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=100, unique=True)), ('framework_type', models.CharField(choices=[('GDPR', 'General Data Protection Regulation'), ('HIPAA', 'Health Insurance Portability and Accountability Act'), ('SOX', 'Sarbanes-Oxley Act'), ('ISO27001', 'ISO/IEC 27001'), ('PCI_DSS', 'Payment Card Industry Data Security Standard'), ('NIST', 'NIST Cybersecurity Framework'), ('CUSTOM', 'Custom Framework')], max_length=20)), ('version', models.CharField(default='1.0', max_length=20)), ('description', models.TextField()), ('applicable_regions', models.JSONField(default=list, help_text='List of applicable regions/countries')), ('industry_sectors', models.JSONField(default=list, help_text='List of applicable industry sectors')), ('compliance_requirements', models.JSONField(default=list, help_text='List of compliance requirements')), ('is_active', models.BooleanField(default=True)), ('effective_date', models.DateField()), ('review_date', models.DateField(blank=True, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name', 'version'], }, ), migrations.CreateModel( name='ExportRequest', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=200)), ('description', models.TextField()), ('request_type', models.CharField(choices=[('REGULATORY', 'Regulatory Request'), ('AUDIT', 'Audit Request'), ('LEGAL', 'Legal Request'), ('INTERNAL', 'Internal Request')], max_length=20)), ('status', models.CharField(choices=[('PENDING', 'Pending'), ('APPROVED', 'Approved'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('REJECTED', 'Rejected'), ('CANCELLED', 'Cancelled')], default='PENDING', max_length=20)), ('requester_name', models.CharField(max_length=200)), ('requester_organization', models.CharField(blank=True, max_length=200, null=True)), ('requester_email', models.EmailField(max_length=254)), ('requester_phone', models.CharField(blank=True, max_length=20, null=True)), ('legal_authority', models.CharField(blank=True, max_length=200, null=True)), ('data_scope', models.JSONField(help_text='Scope of data to be exported')), ('date_range_start', models.DateTimeField(blank=True, null=True)), ('date_range_end', models.DateTimeField(blank=True, null=True)), ('data_classification_levels', models.JSONField(default=list)), ('incident_categories', models.JSONField(default=list)), ('export_format', models.CharField(default='JSON', help_text='Export format (JSON, CSV, XML, PDF)', max_length=20)), ('include_evidence', models.BooleanField(default=True)), ('include_audit_trails', models.BooleanField(default=True)), ('redaction_required', models.BooleanField(default=False)), ('approval_required', models.BooleanField(default=True)), ('approved_at', models.DateTimeField(blank=True, null=True)), ('approval_notes', models.TextField(blank=True, null=True)), ('export_file_path', models.CharField(blank=True, max_length=500, null=True)), ('export_file_hash', models.CharField(blank=True, max_length=64, null=True)), ('export_file_size', models.BigIntegerField(blank=True, null=True)), ('requested_at', models.DateTimeField(auto_now_add=True)), ('due_date', models.DateTimeField(blank=True, null=True)), ('completed_at', models.DateTimeField(blank=True, null=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='approved_exports', to=settings.AUTH_USER_MODEL)), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_exports', to=settings.AUTH_USER_MODEL)), ('executed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='executed_exports', to=settings.AUTH_USER_MODEL)), ('applicable_frameworks', models.ManyToManyField(blank=True, to='compliance_governance.regulatoryframework')), ], options={ 'ordering': ['-requested_at'], }, ), migrations.CreateModel( name='ComplianceRequirement', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('requirement_id', models.CharField(help_text='Unique identifier within framework', max_length=50)), ('title', models.CharField(max_length=200)), ('description', models.TextField()), ('requirement_type', models.CharField(choices=[('TECHNICAL', 'Technical Control'), ('ADMINISTRATIVE', 'Administrative Control'), ('PHYSICAL', 'Physical Control'), ('PROCEDURAL', 'Procedural Control'), ('DOCUMENTATION', 'Documentation Requirement')], max_length=20)), ('priority', models.CharField(choices=[('CRITICAL', 'Critical'), ('HIGH', 'High'), ('MEDIUM', 'Medium'), ('LOW', 'Low')], default='MEDIUM', max_length=10)), ('implementation_guidance', models.TextField(blank=True, null=True)), ('evidence_requirements', models.JSONField(default=list, help_text='Types of evidence required')), ('testing_procedures', models.TextField(blank=True, null=True)), ('is_implemented', models.BooleanField(default=False)), ('implementation_date', models.DateField(blank=True, null=True)), ('last_assessment_date', models.DateField(blank=True, null=True)), ('next_assessment_date', models.DateField(blank=True, null=True)), ('compliance_status', models.CharField(choices=[('COMPLIANT', 'Compliant'), ('PARTIALLY_COMPLIANT', 'Partially Compliant'), ('NON_COMPLIANT', 'Non-Compliant'), ('NOT_ASSESSED', 'Not Assessed')], default='NOT_ASSESSED', max_length=20)), ('responsible_team', models.CharField(blank=True, max_length=100, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ('framework', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requirements', to='compliance_governance.regulatoryframework')), ], options={ 'ordering': ['framework', 'requirement_id'], }, ), migrations.CreateModel( name='ComplianceReport', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=200)), ('report_type', models.CharField(choices=[('ASSESSMENT', 'Compliance Assessment'), ('AUDIT', 'Audit Report'), ('REMEDIATION', 'Remediation Report'), ('STATUS', 'Status Report'), ('EXCEPTION', 'Exception Report')], max_length=20)), ('description', models.TextField()), ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('REVIEW', 'Under Review'), ('APPROVED', 'Approved'), ('PUBLISHED', 'Published'), ('ARCHIVED', 'Archived')], default='DRAFT', max_length=20)), ('executive_summary', models.TextField(blank=True, null=True)), ('findings', models.JSONField(default=list, help_text='List of findings and observations')), ('recommendations', models.JSONField(default=list, help_text='List of recommendations')), ('action_items', models.JSONField(default=list, help_text='List of action items')), ('overall_compliance_score', models.FloatField(blank=True, help_text='Overall compliance score (0-100)', null=True, validators=[django.core.validators.MinValueValidator(0.0), django.core.validators.MaxValueValidator(100.0)])), ('compliance_gaps', models.JSONField(default=list, help_text='List of compliance gaps')), ('risk_assessment', models.JSONField(default=dict, help_text='Risk assessment details')), ('report_period_start', models.DateField()), ('report_period_end', models.DateField()), ('report_file_path', models.CharField(blank=True, max_length=500, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('published_at', models.DateTimeField(blank=True, null=True)), ('approved_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='approved_reports', to=settings.AUTH_USER_MODEL)), ('prepared_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='prepared_reports', to=settings.AUTH_USER_MODEL)), ('reviewed_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='reviewed_reports', to=settings.AUTH_USER_MODEL)), ('applicable_requirements', models.ManyToManyField(blank=True, to='compliance_governance.compliancerequirement')), ('framework', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reports', to='compliance_governance.regulatoryframework')), ], options={ 'ordering': ['-created_at'], }, ), migrations.CreateModel( name='RegulatoryWorkflow', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('name', models.CharField(max_length=200)), ('workflow_type', models.CharField(choices=[('INCIDENT_RESPONSE', 'Incident Response'), ('DATA_BREACH', 'Data Breach Response'), ('AUDIT', 'Audit Process'), ('ASSESSMENT', 'Compliance Assessment'), ('REMEDIATION', 'Remediation Process'), ('DOCUMENTATION', 'Documentation Process')], max_length=30)), ('description', models.TextField()), ('workflow_definition', models.JSONField(help_text='JSON definition of workflow steps and transitions')), ('triggers', models.JSONField(default=list, help_text='Events that trigger this workflow')), ('conditions', models.JSONField(default=dict, help_text='Conditions for workflow execution')), ('status', models.CharField(choices=[('DRAFT', 'Draft'), ('ACTIVE', 'Active'), ('SUSPENDED', 'Suspended'), ('ARCHIVED', 'Archived')], default='DRAFT', max_length=20)), ('version', models.CharField(default='1.0', max_length=20)), ('is_template', models.BooleanField(default=False)), ('notification_rules', models.JSONField(default=list, help_text='Notification rules for workflow events')), ('escalation_rules', models.JSONField(default=list, help_text='Escalation rules for workflow delays')), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('applicable_frameworks', models.ManyToManyField(blank=True, to='compliance_governance.regulatoryframework')), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name', 'version'], }, ), migrations.CreateModel( name='RetentionPolicy', 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()), ('policy_type', models.CharField(choices=[('INCIDENT_DATA', 'Incident Data'), ('AUDIT_LOGS', 'Audit Logs'), ('EVIDENCE', 'Evidence'), ('USER_DATA', 'User Data'), ('SYSTEM_LOGS', 'System Logs'), ('BACKUP_DATA', 'Backup Data'), ('DOCUMENTATION', 'Documentation')], max_length=30)), ('retention_period', models.PositiveIntegerField(help_text='Retention period value')), ('retention_unit', models.CharField(choices=[('DAYS', 'Days'), ('WEEKS', 'Weeks'), ('MONTHS', 'Months'), ('YEARS', 'Years')], default='YEARS', max_length=10)), ('auto_archive', models.BooleanField(default=True, help_text='Automatically archive after retention period')), ('auto_delete', models.BooleanField(default=False, help_text='Automatically delete after retention period')), ('data_classification_levels', models.JSONField(default=list, help_text='Data classification levels this policy applies to')), ('incident_categories', models.JSONField(default=list, help_text='Incident categories this policy applies to')), ('custom_filters', models.JSONField(default=dict, help_text='Custom filters for policy application')), ('legal_hold_override', models.BooleanField(default=True, help_text='Whether legal holds can override this policy')), ('exception_conditions', models.JSONField(default=list, help_text='Conditions that create exceptions to this policy')), ('is_active', models.BooleanField(default=True)), ('effective_date', models.DateField()), ('review_date', models.DateField(blank=True, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('applicable_frameworks', models.ManyToManyField(blank=True, to='compliance_governance.regulatoryframework')), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ['name'], }, ), migrations.CreateModel( name='WorkflowInstance', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=200)), ('description', models.TextField(blank=True, null=True)), ('status', models.CharField(choices=[('PENDING', 'Pending'), ('IN_PROGRESS', 'In Progress'), ('COMPLETED', 'Completed'), ('SUSPENDED', 'Suspended'), ('CANCELLED', 'Cancelled'), ('FAILED', 'Failed')], default='PENDING', max_length=20)), ('current_step', models.CharField(blank=True, max_length=100, null=True)), ('execution_data', models.JSONField(default=dict, help_text='Runtime data for workflow execution')), ('completed_steps', models.JSONField(default=list, help_text='List of completed workflow steps')), ('started_at', models.DateTimeField(auto_now_add=True)), ('completed_at', models.DateTimeField(blank=True, null=True)), ('due_date', models.DateTimeField(blank=True, null=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('assigned_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='created_workflows', to=settings.AUTH_USER_MODEL)), ('related_incident', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='regulatory_workflows', to='incident_intelligence.incident')), ('related_requirement', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='workflow_instances', to='compliance_governance.compliancerequirement')), ('stakeholders', models.ManyToManyField(blank=True, related_name='workflow_stakeholders', to=settings.AUTH_USER_MODEL)), ('workflow', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='instances', to='compliance_governance.regulatoryworkflow')), ], options={ 'ordering': ['-started_at'], }, ), migrations.CreateModel( name='EvidenceCollection', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('title', models.CharField(max_length=200)), ('description', models.TextField()), ('evidence_type', models.CharField(choices=[('LOG_FILE', 'Log File'), ('SCREENSHOT', 'Screenshot'), ('DOCUMENT', 'Document'), ('EMAIL', 'Email'), ('DATABASE_RECORD', 'Database Record'), ('CONFIGURATION', 'Configuration File'), ('AUDIT_TRAIL', 'Audit Trail'), ('TESTIMONY', 'Testimony/Statement'), ('PHYSICAL_EVIDENCE', 'Physical Evidence'), ('DIGITAL_FORENSICS', 'Digital Forensics')], max_length=30)), ('status', models.CharField(choices=[('COLLECTED', 'Collected'), ('VERIFIED', 'Verified'), ('ANALYZED', 'Analyzed'), ('ARCHIVED', 'Archived'), ('DESTROYED', 'Destroyed')], default='COLLECTED', max_length=20)), ('file_path', models.CharField(blank=True, max_length=500, null=True)), ('file_hash', models.CharField(blank=True, help_text='SHA-256 hash for integrity', max_length=64, null=True)), ('file_size', models.BigIntegerField(blank=True, null=True)), ('mime_type', models.CharField(blank=True, max_length=100, null=True)), ('collection_method', models.CharField(blank=True, max_length=100, null=True)), ('collection_timestamp', models.DateTimeField(auto_now_add=True)), ('collection_location', models.CharField(blank=True, max_length=200, null=True)), ('collection_notes', models.TextField(blank=True, null=True)), ('custody_chain', models.JSONField(default=list, help_text='Chain of custody records')), ('retention_period', models.DurationField(blank=True, null=True)), ('disposal_date', models.DateTimeField(blank=True, null=True)), ('disposal_method', models.CharField(blank=True, max_length=100, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('collected_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='collected_evidence', to=settings.AUTH_USER_MODEL)), ('compliance_requirement', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evidence_collection', to='compliance_governance.compliancerequirement')), ('incident', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='evidence_collection', to='incident_intelligence.incident')), ('verified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='verified_evidence', to=settings.AUTH_USER_MODEL)), ('workflow_instance', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='evidence_collection', to='compliance_governance.workflowinstance')), ], options={ 'ordering': ['-collection_timestamp'], }, ), migrations.CreateModel( name='LegalHold', fields=[ ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), ('case_name', models.CharField(max_length=200)), ('case_number', models.CharField(blank=True, max_length=100, null=True)), ('description', models.TextField()), ('status', models.CharField(choices=[('ACTIVE', 'Active'), ('SUSPENDED', 'Suspended'), ('RELEASED', 'Released'), ('EXPIRED', 'Expired')], default='ACTIVE', max_length=20)), ('legal_counsel', models.CharField(blank=True, max_length=200, null=True)), ('law_firm', models.CharField(blank=True, max_length=200, null=True)), ('court_jurisdiction', models.CharField(blank=True, max_length=200, null=True)), ('data_scope', models.JSONField(help_text='Scope of data covered by this hold')), ('custodian_list', models.JSONField(default=list, help_text='List of data custodians')), ('search_criteria', models.JSONField(default=dict, help_text='Search criteria for data collection')), ('hold_date', models.DateField(help_text='Date the legal hold was issued')), ('release_date', models.DateField(blank=True, null=True)), ('expiration_date', models.DateField(blank=True, null=True)), ('notification_sent', models.BooleanField(default=False)), ('notification_date', models.DateTimeField(blank=True, null=True)), ('reminder_sent', models.BooleanField(default=False)), ('reminder_date', models.DateTimeField(blank=True, null=True)), ('created_at', models.DateTimeField(auto_now_add=True)), ('updated_at', models.DateTimeField(auto_now=True)), ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)), ('related_evidence', models.ManyToManyField(blank=True, related_name='legal_holds', to='compliance_governance.evidencecollection')), ('related_incidents', models.ManyToManyField(blank=True, related_name='legal_holds', to='incident_intelligence.incident')), ], options={ 'ordering': ['-hold_date'], 'indexes': [models.Index(fields=['status', 'hold_date'], name='compliance__status_33a9b6_idx'), models.Index(fields=['expiration_date'], name='compliance__expirat_3d41f9_idx')], }, ), migrations.AddIndex( model_name='regulatoryframework', index=models.Index(fields=['framework_type', 'is_active'], name='compliance__framewo_a67fc4_idx'), ), migrations.AddIndex( model_name='regulatoryframework', index=models.Index(fields=['effective_date'], name='compliance__effecti_42b42f_idx'), ), migrations.AddIndex( model_name='exportrequest', index=models.Index(fields=['request_type', 'status'], name='compliance__request_8dd8b7_idx'), ), migrations.AddIndex( model_name='exportrequest', index=models.Index(fields=['status', 'due_date'], name='compliance__status_dadc69_idx'), ), migrations.AddIndex( model_name='exportrequest', index=models.Index(fields=['requester_email'], name='compliance__request_a06e63_idx'), ), migrations.AddIndex( model_name='compliancerequirement', index=models.Index(fields=['framework', 'compliance_status'], name='compliance__framewo_72cd4e_idx'), ), migrations.AddIndex( model_name='compliancerequirement', index=models.Index(fields=['requirement_type', 'priority'], name='compliance__require_6eb886_idx'), ), migrations.AddIndex( model_name='compliancerequirement', index=models.Index(fields=['next_assessment_date'], name='compliance__next_as_0fca2f_idx'), ), migrations.AlterUniqueTogether( name='compliancerequirement', unique_together={('framework', 'requirement_id')}, ), migrations.AddIndex( model_name='compliancereport', index=models.Index(fields=['framework', 'report_type'], name='compliance__framewo_04b02e_idx'), ), migrations.AddIndex( model_name='compliancereport', index=models.Index(fields=['status', 'report_period_end'], name='compliance__status_adc275_idx'), ), migrations.AddIndex( model_name='regulatoryworkflow', index=models.Index(fields=['workflow_type', 'status'], name='compliance__workflo_ceb72e_idx'), ), migrations.AddIndex( model_name='regulatoryworkflow', index=models.Index(fields=['is_template'], name='compliance__is_temp_0fed32_idx'), ), migrations.AddIndex( model_name='retentionpolicy', index=models.Index(fields=['policy_type', 'is_active'], name='compliance__policy__c9edd3_idx'), ), migrations.AddIndex( model_name='retentionpolicy', index=models.Index(fields=['effective_date'], name='compliance__effecti_6aa9ee_idx'), ), migrations.AddIndex( model_name='workflowinstance', index=models.Index(fields=['workflow', 'status'], name='compliance__workflo_96e550_idx'), ), migrations.AddIndex( model_name='workflowinstance', index=models.Index(fields=['status', 'due_date'], name='compliance__status_96c3cc_idx'), ), migrations.AddIndex( model_name='workflowinstance', index=models.Index(fields=['assigned_to', 'status'], name='compliance__assigne_96daf0_idx'), ), migrations.AddIndex( model_name='evidencecollection', index=models.Index(fields=['incident', 'evidence_type'], name='compliance__inciden_b30335_idx'), ), migrations.AddIndex( model_name='evidencecollection', index=models.Index(fields=['status', 'collection_timestamp'], name='compliance__status_515c91_idx'), ), migrations.AddIndex( model_name='evidencecollection', index=models.Index(fields=['compliance_requirement'], name='compliance__complia_5d81da_idx'), ), ]