# Generated by Django 3.2 on 2021-04-28 17:16

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


class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
            ],
            options={
                'ordering': ['name'],
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Contract',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100, unique=True)),
                ('begin', models.DateField()),
                ('end', models.DateField()),
                ('description', models.TextField()),
            ],
        ),
        migrations.CreateModel(
            name='Credential',
            fields=[
                ('credential_id', models.AutoField(primary_key=True, serialize=False)),
                ('username', fernet_fields.fields.EncryptedCharField(max_length=50)),
                ('password', fernet_fields.fields.EncryptedCharField(max_length=50)),
                ('enable_password', fernet_fields.fields.EncryptedCharField(max_length=50)),
                ('instructions', fernet_fields.fields.EncryptedCharField(blank=True, max_length=255, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='ISP',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
            ],
            options={
                'ordering': ['name'],
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Manufacturer',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50, unique=True)),
            ],
            options={
                'ordering': ['name'],
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='CI',
            fields=[
                ('credential_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='cis.credential')),
                ('hostname', models.CharField(max_length=50)),
                ('ip', models.GenericIPAddressField()),
                ('description', models.CharField(max_length=255)),
                ('deployed', models.BooleanField(default=False)),
                ('business_impact', models.PositiveSmallIntegerField(choices=[(0, 'low'), (1, 'medium'), (2, 'high')], default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(2)])),
                ('status', models.PositiveSmallIntegerField(choices=[(0, 'created'), (1, 'sent'), (2, 'approved')], default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(2)])),
            ],
            options={
                'ordering': ['hostname'],
            },
            bases=('cis.credential',),
        ),
        migrations.CreateModel(
            name='Place',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('description', models.CharField(blank=True, max_length=255, null=True)),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.client')),
            ],
        ),
        migrations.CreateModel(
            name='Circuit',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('identifier', models.CharField(max_length=50)),
                ('bandwidth', models.CharField(max_length=10)),
                ('type', models.CharField(max_length=50)),
                ('description', models.CharField(max_length=255)),
                ('isp', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.isp')),
                ('place', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.place')),
            ],
        ),
        migrations.CreateModel(
            name='CIPack',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('sent_at', models.DateTimeField(auto_now_add=True, null=True)),
                ('approved_by', models.ForeignKey(limit_choices_to={'is_superuser': True}, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='cipacks_approved', to=settings.AUTH_USER_MODEL)),
                ('responsible', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Appliance',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('serial_number', models.CharField(max_length=255, unique=True)),
                ('model', models.CharField(max_length=100)),
                ('virtual', models.BooleanField(default=False)),
                ('client', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.client')),
                ('manufacturer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='cis.manufacturer')),
            ],
            options={
                'ordering': ['serial_number'],
            },
        ),
        migrations.AddConstraint(
            model_name='place',
            constraint=models.UniqueConstraint(fields=('client', 'name'), name='unique_client_place_name'),
        ),
        migrations.AddField(
            model_name='ci',
            name='appliances',
            field=models.ManyToManyField(to='cis.Appliance'),
        ),
        migrations.AddField(
            model_name='ci',
            name='client',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.client'),
        ),
        migrations.AddField(
            model_name='ci',
            name='contract',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='cis.contract'),
        ),
        migrations.AddField(
            model_name='ci',
            name='pack',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='cis.cipack'),
        ),
        migrations.AddField(
            model_name='ci',
            name='place',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cis.place'),
        ),
        migrations.AddConstraint(
            model_name='ci',
            constraint=models.UniqueConstraint(fields=('client', 'hostname', 'ip', 'description'), name='unique_client_hostname_ip_description'),
        ),
    ]
