# Generated by Django 5.2.15 on 2026-06-14 19:07

import django.core.validators
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('eveuniverse', '0012_alter_evebloodline_eve_ship_type'),
        ('fitcheck', '0009_source_plugin_pk'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='FitAssignment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('notes', models.CharField(blank=True, max_length=255)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                ('doctrine', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='fitcheck.doctrine')),
                ('fit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assignments', to='fitcheck.doctrinefit')),
            ],
            options={
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='AssignmentItemPolicy',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('section', models.CharField(choices=[('HIGH', 'High slots'), ('MED', 'Mid slots'), ('LOW', 'Low slots'), ('RIG', 'Rigs'), ('SUBSYS', 'Subsystems'), ('DRONE', 'Drone bay'), ('FIGHTER', 'Fighter bay'), ('CARGO', 'Cargo'), ('IMPLANT', 'Implants')], max_length=8)),
                ('quantity', models.PositiveIntegerField(default=1)),
                ('policy', models.CharField(choices=[('EX', 'Exact type only'), ('VA', 'Variant family (meta filtered)'), ('MB', 'Any equivalent that meets or beats attributes'), ('AN', 'No enforcement (anything accepted)')], max_length=2)),
                ('min_meta_level', models.PositiveSmallIntegerField(blank=True, null=True)),
                ('allowed_meta_groups', models.JSONField(blank=True, default=list)),
                ('checked_attributes', models.JSONField(blank=True, default=list)),
                ('allow_mutated', models.BooleanField(default=True)),
                ('min_quantity_pct', models.PositiveSmallIntegerField(default=100, validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(100)])),
                ('notes', models.CharField(blank=True, max_length=255)),
                ('charge_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='eveuniverse.evetype')),
                ('module_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='eveuniverse.evetype')),
                ('source_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='assignment_policies', to='fitcheck.doctrinefititem')),
                ('assignment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='item_policies', to='fitcheck.fitassignment')),
            ],
            options={
                'default_permissions': (),
            },
        ),
        migrations.CreateModel(
            name='AssignmentItemOverride',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('mode', models.CharField(choices=[('I', 'Always allow'), ('E', 'Never allow')], max_length=1)),
                ('alt_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='eveuniverse.evetype')),
                ('assignment_item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='overrides', to='fitcheck.assignmentitempolicy')),
            ],
            options={
                'default_permissions': (),
                'constraints': [models.UniqueConstraint(fields=('assignment_item', 'alt_type'), name='fitcheck_unique_assignment_override')],
            },
        ),
        migrations.AddConstraint(
            model_name='fitassignment',
            constraint=models.UniqueConstraint(fields=('doctrine', 'fit'), name='fitcheck_unique_assignment'),
        ),
        migrations.AddIndex(
            model_name='assignmentitempolicy',
            index=models.Index(fields=['assignment', 'section'], name='fitcheck_as_assignm_764b0c_idx'),
        ),
        migrations.AddConstraint(
            model_name='assignmentitempolicy',
            constraint=models.UniqueConstraint(fields=('assignment', 'source_item'), name='fitcheck_unique_assignment_item'),
        ),
    ]
