# Generated by Django 2.2.11 on 2020-06-11 08:06

import care.facility.models.mixins.permissions.facility
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import partial_index
import uuid


class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('facility', '0114_auto_20200610_1720'),
    ]

    operations = [
        migrations.CreateModel(
            name='FacilityInventoryItem',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=1000)),
                ('description', models.TextField(blank=True)),
                ('min_quantity', models.FloatField()),
            ],
        ),
        migrations.CreateModel(
            name='FacilityInventoryItemTag',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
            ],
        ),
        migrations.CreateModel(
            name='FacilityInventoryUnit',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
            ],
        ),
        migrations.CreateModel(
            name='FacilityInventoryUnitConverter',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('multiplier', models.FloatField()),
                ('from_unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='from_unit', to='facility.FacilityInventoryUnit')),
                ('to_unit', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='to_unit', to='facility.FacilityInventoryUnit')),
            ],
        ),
        migrations.CreateModel(
            name='FacilityInventorySummary',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('external_id', models.UUIDField(db_index=True, default=uuid.uuid4, unique=True)),
                ('created_date', models.DateTimeField(auto_now_add=True, null=True)),
                ('modified_date', models.DateTimeField(auto_now=True, null=True)),
                ('deleted', models.BooleanField(default=False)),
                ('quantity', models.FloatField(default=0)),
                ('is_low', models.BooleanField(default=False)),
                ('facility', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='facility.Facility')),
                ('item', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='facility.FacilityInventoryItem')),
            ],
            bases=(models.Model, care.facility.models.mixins.permissions.facility.FacilityRelatedPermissionMixin),
        ),
        migrations.CreateModel(
            name='FacilityInventoryLog',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('external_id', models.UUIDField(db_index=True, default=uuid.uuid4, unique=True)),
                ('created_date', models.DateTimeField(auto_now_add=True, null=True)),
                ('modified_date', models.DateTimeField(auto_now=True, null=True)),
                ('deleted', models.BooleanField(default=False)),
                ('quantity', models.FloatField(default=0)),
                ('is_incoming', models.BooleanField()),
                ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
                ('facility', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='facility.Facility')),
                ('item', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='facility.FacilityInventoryItem')),
                ('unit', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='facility.FacilityInventoryUnit')),
            ],
            options={
                'abstract': False,
            },
            bases=(models.Model, care.facility.models.mixins.permissions.facility.FacilityRelatedPermissionMixin),
        ),
        migrations.AddField(
            model_name='facilityinventoryitem',
            name='allowed_units',
            field=models.ManyToManyField(related_name='allowed_units', to='facility.FacilityInventoryUnit'),
        ),
        migrations.AddField(
            model_name='facilityinventoryitem',
            name='default_unit',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='default_unit', to='facility.FacilityInventoryUnit'),
        ),
        migrations.AddField(
            model_name='facilityinventoryitem',
            name='tags',
            field=models.ManyToManyField(to='facility.FacilityInventoryItemTag'),
        ),
        migrations.AddIndex(
            model_name='facilityinventorysummary',
            index=partial_index.PartialIndex(fields=['facility', 'item'], name='facility_fa_facilit_ff33b8_partial', unique=True, where=partial_index.PQ(deleted=False)),
        ),
    ]
