# Generated by Django 4.0 on 2025-09-20 15:55

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='RiskCategory',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True)),
            ],
            options={
                'verbose_name_plural': 'Risk Categories',
            },
        ),
        migrations.CreateModel(
            name='Risk',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=200)),
                ('description', models.TextField()),
                ('likelihood', models.IntegerField(help_text='Likelihood score (1-5)')),
                ('impact', models.IntegerField(help_text='Impact score (1-5)')),
                ('risk_score', models.DecimalField(blank=True, decimal_places=2, max_digits=5, null=True)),
                ('priority', models.CharField(choices=[('LOW', 'Low'), ('MEDIUM', 'Medium'), ('HIGH', 'High'), ('CRITICAL', 'Critical')], default='MEDIUM', max_length=20)),
                ('mitigation_plan', models.TextField(blank=True)),
                ('status', models.CharField(choices=[('IDENTIFIED', 'Identified'), ('ASSESSED', 'Assessed'), ('MITIGATING', 'Mitigating'), ('MONITORING', 'Monitoring'), ('CLOSED', 'Closed')], default='IDENTIFIED', max_length=20)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('updated_at', models.DateTimeField(auto_now=True)),
                ('due_date', models.DateField(blank=True, null=True)),
                ('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='risks', to='risk.riskcategory')),
                ('identified_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='identified_risks', to=settings.AUTH_USER_MODEL)),
                ('mitigation_owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='mitigation_risks', to=settings.AUTH_USER_MODEL)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owned_risks', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'ordering': ['-created_at'],
            },
        ),
        migrations.CreateModel(
            name='RiskMitigation',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('action', models.CharField(max_length=200)),
                ('description', models.TextField()),
                ('due_date', models.DateField()),
                ('completed', models.BooleanField(default=False)),
                ('completion_date', models.DateField(blank=True, null=True)),
                ('created_at', models.DateTimeField(default=django.utils.timezone.now)),
                ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('risk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='mitigations', to='risk.risk')),
            ],
        ),
        migrations.CreateModel(
            name='RiskReview',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comments', models.TextField()),
                ('review_date', models.DateTimeField(default=django.utils.timezone.now)),
                ('reviewer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
                ('risk', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='risk.risk')),
            ],
        ),
    ]