# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-12-14 16:46
from __future__ import unicode_literals

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('orgs', '0003_auto_20160412_1123'),
        ('data_importer', '0009_importfile_uploaded_filename'),
        ('seed', '0077_auto_20171201_1323'),
    ]

    operations = [
        migrations.CreateModel(
            name='BuildingFile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('modified', models.DateTimeField(auto_now=True)),
                ('file', models.FileField(blank=True, max_length=500, null=True, upload_to='buildingsync_files')),
                ('file_type', models.IntegerField(choices=[(0, 'Unknown'), (1, 'BuildingSync'), (2, 'GeoJSON'), (3, 'HPXML')], default=0)),
                ('filename', models.CharField(blank=True, max_length=255)),
            ],
        ),
        migrations.CreateModel(
            name='Measure',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('display_name', models.CharField(max_length=255)),
                ('category', models.CharField(max_length=255)),
                ('category_display_name', models.CharField(max_length=255)),
                ('created', models.DateTimeField(auto_now_add=True)),
                ('modified', models.DateTimeField(auto_now=True)),
                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='orgs.Organization')),
            ],
            options={
                'ordering': ['-created'],
                'get_latest_by': 'created',
            },
        ),
        migrations.CreateModel(
            name='PropertyMeasure',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('property_measure_name', models.CharField(max_length=255)),
                ('description', models.TextField(null=True)),
                ('implementation_status', models.IntegerField(choices=[(1, 'Proposed'), (2, 'Evaluated'), (3, 'Selected'), (4, 'Initiated'), (5, 'Discarded'), (6, 'In Progress'), (7, 'Completed'), (8, 'MV'), (9, 'Verified'), (10, 'Unsatisfactory')], default=1)),
                ('application_scale', models.IntegerField(choices=[(1, 'Individual system'), (2, 'Multiple systems'), (3, 'Individual premise'), (4, 'Multiple premises'), (5, 'Entire facility'), (6, 'Entire site')], default=5)),
                ('recommended', models.BooleanField(default=False)),
                ('cost_mv', models.FloatField(null=True)),
                ('cost_total_first', models.FloatField(null=True)),
                ('cost_installation', models.FloatField(null=True)),
                ('cost_material', models.FloatField(null=True)),
                ('cost_capital_replacement', models.FloatField(null=True)),
                ('cost_residual_value', models.FloatField(null=True)),
                ('category_affected', models.IntegerField(choices=[(0, 'Air Distribution'), (1, 'Heating System'), (2, 'Cooling System'), (3, 'Other HVAC'), (4, 'Lighting'), (5, 'Domestic Hot Water'), (6, 'Cooking'), (7, 'Refrigeration'), (8, 'Dishwasher'), (9, 'Laundry'), (10, 'Pump'), (11, 'Fan'), (12, 'Motor'), (13, 'Heat Recovery'), (14, 'Wall'), (15, 'Roof'), (16, 'Ceiling'), (17, 'Fenestration'), (18, 'Foundation'), (19, 'General Controls and Operations'), (20, 'Critical IT System'), (21, 'Plug Load'), (22, 'Process Load'), (23, 'Conveyance'), (24, 'On-Site Storage, Transmission, Generation'), (25, 'Pool'), (26, 'Water Use'), (27, 'Other')], default=27)),
                ('measure', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='seed.Measure')),
            ],
        ),
        migrations.CreateModel(
            name='ResultFile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('file', models.FileField(blank=True, max_length=500, null=True, upload_to='simulation_files')),
                ('file_size_in_bytes', models.IntegerField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Scenario',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=255)),
                ('temporal_status', models.IntegerField(choices=[(1, 'Pre retrofit'), (2, 'Post retrofit'), (3, 'Baseline'), (4, 'Current'), (5, 'Target'), (6, 'Design Target')], default=4)),
                ('description', models.TextField(null=True)),
                ('annual_site_energy_savings', models.FloatField(null=True)),
                ('annual_source_energy_savings', models.FloatField(null=True)),
                ('annual_cost_savings', models.FloatField(null=True)),
                ('summer_peak_load_reduction', models.FloatField(null=True)),
                ('winter_peak_load_reduction', models.FloatField(null=True)),
                ('hdd', models.FloatField(null=True)),
                ('hdd_base_temperature', models.FloatField(null=True)),
                ('cdd', models.FloatField(null=True)),
                ('cdd_base_temperature', models.FloatField(null=True)),
                ('analysis_start_time', models.DateTimeField(null=True)),
                ('analysis_end_time', models.DateTimeField(null=True)),
                ('analysis_state', models.IntegerField(choices=[(0, 'Not Started'), (1, 'Started'), (2, 'Completed'), (3, 'Failed')], default=0)),
                ('analysis_state_message', models.TextField(null=True)),
                ('measures', models.ManyToManyField(to='seed.PropertyMeasure')),
            ],
        ),
        migrations.CreateModel(
            name='Simulation',
            fields=[
                ('property_state', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, primary_key=True, serialize=False, to='seed.PropertyState')),
                ('data', models.JSONField(blank=True, default=dict)),
                ('scenario', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='simulations', to='seed.Scenario')),
            ],
        ),
        migrations.RemoveField(
            model_name='meter',
            name='building_snapshot',
        ),
        migrations.AddField(
            model_name='meter',
            name='property_view',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='meters', to='seed.PropertyView'),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='analysis_end_time',
            field=models.DateTimeField(null=True),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='analysis_start_time',
            field=models.DateTimeField(null=True),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='analysis_state',
            field=models.IntegerField(choices=[(0, 'Not Started'), (1, 'Started'), (2, 'Completed'), (3, 'Failed')], default=0, null=True),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='analysis_state_message',
            field=models.TextField(null=True),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='site_eui_modeled',
            field=models.FloatField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='source_eui_modeled',
            field=models.FloatField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name='cycle',
            name='organization',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='cycles', to='orgs.Organization'),
        ),
        migrations.AlterField(
            model_name='timeseries',
            name='begin_time',
            field=models.DateTimeField(blank=True, db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name='timeseries',
            name='end_time',
            field=models.DateTimeField(blank=True, db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name='timeseries',
            name='meter',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='seed.Meter'),
        ),
        migrations.AddField(
            model_name='propertystate',
            name='measures',
            field=models.ManyToManyField(through='seed.PropertyMeasure', to='seed.Measure'),
        ),
        migrations.AlterIndexTogether(
            name='propertystate',
            index_together=set([('import_file', 'data_state'), ('analysis_state', 'organization'), ('import_file', 'data_state', 'merge_state')]),
        ),
        migrations.AlterIndexTogether(
            name='timeseries',
            index_together=set([('begin_time', 'end_time')]),
        ),
        migrations.AddField(
            model_name='scenario',
            name='property_state',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='scenarios', to='seed.PropertyState'),
        ),
        migrations.AddField(
            model_name='scenario',
            name='reference_case',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='seed.Scenario'),
        ),
        migrations.AddField(
            model_name='resultfile',
            name='simulation',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='files', to='seed.Simulation'),
        ),
        migrations.AddField(
            model_name='propertymeasure',
            name='property_state',
            field=models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='seed.PropertyState'),
        ),
        migrations.AddField(
            model_name='measure',
            name='properties',
            field=models.ManyToManyField(through='seed.PropertyMeasure', to='seed.PropertyState'),
        ),
        migrations.AddField(
            model_name='buildingfile',
            name='property_state',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='building_files', to='seed.PropertyState'),
        ),
        migrations.AddField(
            model_name='meter',
            name='scenario',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='meters', to='seed.Scenario'),
        ),
        migrations.AlterUniqueTogether(
            name='propertymeasure',
            unique_together=set([('property_state', 'measure', 'application_scale', 'implementation_status')]),
        ),
        migrations.AlterIndexTogether(
            name='propertymeasure',
            index_together=set([('property_measure_name', 'property_state')]),
        ),
        migrations.AlterUniqueTogether(
            name='measure',
            unique_together=set([('organization', 'category', 'name')]),
        ),
    ]
