# Generated by Django 3.0.8 on 2020-08-01 04:41

import bitfield.models
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
import isc_common.fields.code_field
import isc_common.fields.description_field
import isc_common.fields.name_field
import isc_common.fields.related


class Migration(migrations.Migration):

    dependencies = [
        ('production', '0296_auto_20200731_1716'),
    ]

    operations = [
        migrations.CreateModel(
            name='Operations_ext_view',
            fields=[
                ('id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='Идентификатор')),
                ('deleted_at', models.DateTimeField(blank=True, db_index=True, null=True, verbose_name='Дата мягкого удаления')),
                ('editing', models.BooleanField(default=True, verbose_name='Возможность редактирования')),
                ('deliting', models.BooleanField(default=True, verbose_name='Возможность удаления')),
                ('lastmodified', models.DateTimeField(db_index=True, default=django.utils.timezone.now, editable=False, verbose_name='Последнее обновление')),
                ('code', isc_common.fields.code_field.CodeField(blank=True, null=True)),
                ('name', isc_common.fields.name_field.NameField(blank=True, null=True)),
                ('description', isc_common.fields.description_field.DescriptionField(db_index=True)),
                ('isFolder', models.BooleanField()),
                ('transportation', models.BooleanField()),
                ('props', bitfield.models.BitField((('assemly', 'Операция комплектации'), ('made_common_form', 'Формировать общий документ'), ('transportation', 'Операция транспортировки')), db_index=True, default=0)),
                ('direction', isc_common.fields.name_field.NameField(blank=True, null=True)),
                ('direction_name', models.TextField()),
            ],
            options={
                'verbose_name': 'Операции',
                'db_table': 'production_operations_item_view',
                'managed': False,
            },
        ),
        migrations.RemoveConstraint(
            model_name='launch_operation_resources',
            name='Launch_operation_resources_unique_constraint_0',
        ),
        migrations.RemoveConstraint(
            model_name='launch_operation_resources',
            name='Launch_operation_resources_unique_constraint_1',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_0',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_1',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_2',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_3',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_4',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_5',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_6',
        ),
        migrations.RemoveConstraint(
            model_name='operation_def_resources',
            name='Operation_def_resources_unique_constraint_7',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_0',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_1',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_2',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_3',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_4',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_5',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_6',
        ),
        migrations.RemoveConstraint(
            model_name='operation_resources',
            name='Operation_resources_unique_constraint_7',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_0',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_1',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_2',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_3',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_4',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_5',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_6',
        ),
        migrations.RemoveConstraint(
            model_name='operations_template_resource',
            name='Operations_template_resource_unique_constraint_7',
        ),
        migrations.AddField(
            model_name='launch_operation_resources',
            name='resource_fin',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Launch_operation_resources_resource_fin', to='production.Resource'),
        ),
        migrations.AddField(
            model_name='operation_def_resources',
            name='resource_fin',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operation_def_resources_fin', to='production.Resource'),
        ),
        migrations.AddField(
            model_name='operation_resources',
            name='resource_fin',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operation_resources_resource_fin', to='production.Resource'),
        ),
        migrations.AddField(
            model_name='operations_template_resource',
            name='resource_fin',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operations_template_resource_resource_fin', to='production.Resource'),
        ),
        migrations.AlterField(
            model_name='launch_operation_resources',
            name='resource',
            field=isc_common.fields.related.ForeignKeyProtect(on_delete=django.db.models.deletion.PROTECT, related_name='Launch_operation_resources_resource', to='production.Resource'),
        ),
        migrations.AlterField(
            model_name='operation_def_resources',
            name='resource',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operation_def_resources_resource', to='production.Resource'),
        ),
        migrations.AlterField(
            model_name='operation_resources',
            name='resource',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operation_resources_resource', to='production.Resource'),
        ),
        migrations.AlterField(
            model_name='operations_template_resource',
            name='resource',
            field=isc_common.fields.related.ForeignKeyProtect(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='Operations_template_resource_resource', to='production.Resource'),
        ),
        migrations.AddConstraint(
            model_name='launch_operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource_fin', None)), fields=('launch_operationitem', 'location', 'resource'), name='Launch_operation_resources_unique_constraint_0'),
        ),
        migrations.AddConstraint(
            model_name='launch_operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(location_fin=None), fields=('launch_operationitem', 'location', 'resource', 'resource_fin'), name='Launch_operation_resources_unique_constraint_1'),
        ),
        migrations.AddConstraint(
            model_name='launch_operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(resource_fin=None), fields=('launch_operationitem', 'location', 'location_fin', 'resource'), name='Launch_operation_resources_unique_constraint_2'),
        ),
        migrations.AddConstraint(
            model_name='launch_operation_resources',
            constraint=models.UniqueConstraint(fields=('launch_operationitem', 'location', 'location_fin', 'resource', 'resource_fin'), name='Launch_operation_resources_unique_constraint_3'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource_fin', None)), fields=('operation', 'resource'), name='Operation_def_resources_unique_constraint_1'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource', None)), fields=('operation', 'resource_fin'), name='Operation_def_resources_unique_constraint_2'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None)), fields=('operation', 'resource', 'resource_fin'), name='Operation_def_resources_unique_constraint_3'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None), ('resource_fin', None)), fields=('location_fin', 'operation'), name='Operation_def_resources_unique_constraint_4'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource_fin', None)), fields=('location_fin', 'operation', 'resource'), name='Operation_def_resources_unique_constraint_5'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None)), fields=('location_fin', 'operation', 'resource_fin'), name='Operation_def_resources_unique_constraint_6'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(location=None), fields=('location_fin', 'operation', 'resource', 'resource_fin'), name='Operation_def_resources_unique_constraint_7'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None), ('resource_fin', None)), fields=('location', 'operation'), name='Operation_def_resources_unique_constraint_8'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource_fin', None)), fields=('location', 'operation', 'resource'), name='Operation_def_resources_unique_constraint_9'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None)), fields=('location', 'operation', 'resource_fin'), name='Operation_def_resources_unique_constraint_10'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(location_fin=None), fields=('location', 'operation', 'resource', 'resource_fin'), name='Operation_def_resources_unique_constraint_11'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('resource', None), ('resource_fin', None)), fields=('location', 'location_fin', 'operation'), name='Operation_def_resources_unique_constraint_12'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(resource_fin=None), fields=('location', 'location_fin', 'operation', 'resource'), name='Operation_def_resources_unique_constraint_13'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(condition=models.Q(resource=None), fields=('location', 'location_fin', 'operation', 'resource_fin'), name='Operation_def_resources_unique_constraint_14'),
        ),
        migrations.AddConstraint(
            model_name='operation_def_resources',
            constraint=models.UniqueConstraint(fields=('location', 'location_fin', 'operation', 'resource', 'resource_fin'), name='Operation_def_resources_unique_constraint_15'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource', None), ('resource_fin', None)), fields=('operationitem',), name='Operation_resources_unique_constraint_0'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource_fin', None)), fields=('operationitem', 'resource'), name='Operation_resources_unique_constraint_1'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource', None)), fields=('operationitem', 'resource_fin'), name='Operation_resources_unique_constraint_2'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None)), fields=('operationitem', 'resource', 'resource_fin'), name='Operation_resources_unique_constraint_3'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None), ('resource_fin', None)), fields=('location', 'operationitem'), name='Operation_resources_unique_constraint_4'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource_fin', None)), fields=('location', 'operationitem', 'resource'), name='Operation_resources_unique_constraint_5'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None)), fields=('location', 'operationitem', 'resource_fin'), name='Operation_resources_unique_constraint_6'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(location_fin=None), fields=('location', 'operationitem', 'resource', 'resource_fin'), name='Operation_resources_unique_constraint_7'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None), ('resource_fin', None)), fields=('location_fin', 'operationitem'), name='Operation_resources_unique_constraint_8'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource_fin', None)), fields=('location_fin', 'operationitem', 'resource'), name='Operation_resources_unique_constraint_9'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None)), fields=('location_fin', 'operationitem', 'resource_fin'), name='Operation_resources_unique_constraint_10'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(location=None), fields=('location_fin', 'operationitem', 'resource', 'resource_fin'), name='Operation_resources_unique_constraint_111'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(('resource', None), ('resource_fin', None)), fields=('location', 'location_fin', 'operationitem'), name='Operation_resources_unique_constraint_12'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(resource_fin=None), fields=('location', 'location_fin', 'operationitem', 'resource'), name='Operation_resources_unique_constraint_13'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(condition=models.Q(resource=None), fields=('location', 'location_fin', 'operationitem', 'resource_fin'), name='Operation_resources_unique_constraint_14'),
        ),
        migrations.AddConstraint(
            model_name='operation_resources',
            constraint=models.UniqueConstraint(fields=('location', 'location_fin', 'operationitem', 'resource', 'resource_fin'), name='Operation_resources_unique_constraint_15'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource', None), ('resource_fin', None)), fields=('template',), name='Operations_template_resource_unique_constraint_0'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource_fin', None)), fields=('resource', 'template'), name='Operations_template_resource_unique_constraint_1'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None), ('resource', None)), fields=('resource_fin', 'template'), name='Operations_template_resource_unique_constraint_2'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('location_fin', None)), fields=('resource', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_3'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None), ('resource_fin', None)), fields=('location', 'template'), name='Operations_template_resource_unique_constraint_4'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource_fin', None)), fields=('location', 'resource', 'template'), name='Operations_template_resource_unique_constraint_5'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location_fin', None), ('resource', None)), fields=('location', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_6'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(location_fin=None), fields=('location', 'resource', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_7'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None), ('resource_fin', None)), fields=('location_fin', 'template'), name='Operations_template_resource_unique_constraint_8'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource_fin', None)), fields=('location_fin', 'resource', 'template'), name='Operations_template_resource_unique_constraint_9'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('location', None), ('resource', None)), fields=('location_fin', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_10'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(location=None), fields=('location_fin', 'resource', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_11'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(('resource', None), ('resource_fin', None)), fields=('location', 'location_fin', 'template'), name='Operations_template_resource_unique_constraint_12'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(resource_fin=None), fields=('location', 'location_fin', 'resource', 'template'), name='Operations_template_resource_unique_constraint_13'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(condition=models.Q(resource=None), fields=('location', 'location_fin', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_14'),
        ),
        migrations.AddConstraint(
            model_name='operations_template_resource',
            constraint=models.UniqueConstraint(fields=('location', 'location_fin', 'resource', 'resource_fin', 'template'), name='Operations_template_resource_unique_constraint_15'),
        ),
    ]
