text: # Generated by Django 2.2.6 on 2019-11-12 13:20
  from pathlib import PurePath
  
  from django.conf import settings
  from django.db import migrations, models
  import django.db.models.deletion
  import mptt.fields
  import uuid
  
  from datahub.core.migration_utils import load_yaml_data_in_migration
  
  fixtures = [
      PurePath(__file__).parent / '0001_activity_type.yaml',
      PurePath(__file__).parent / '0001_fdi_sicgrouping.yaml',
      PurePath(__file__).parent / '0001_gvamultiplier.yaml',
      PurePath(__file__).parent / '0001_initial_delivery_partners.yaml',
      PurePath(__file__).parent / '0001_initial_likelihood_to_land.yaml',
      PurePath(__file__).parent / '0001_investmentsector.yaml',
      PurePath(__file__).parent / '0001_project_manager_request_status.yaml',
  ]
  
  
  def load_fixtures(apps, schema_editor):
      for fixture in fixtures:
          load_yaml_data_in_migration(apps, fixture)
  
  
  class Migration(migrations.Migration):
      initial = True
  
      dependencies = [
          migrations.swappable_dependency(settings.AUTH_USER_MODEL),
          ('metadata', '0001_squashed_0010_auto_20180613_1553'),
          ('company', '0001_squashed_0096_company_global_ultimate_duns_number'),
          ('reversion', '0001_squashed_0004_auto_20160611_1202'),
          ('documents', '0001_initial'),
      ]
  
      operations = [
          migrations.CreateModel(
              name='InvestorType',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='Involvement',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='SpecificProgramme',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='InvestmentDeliveryPartner',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='LikelihoodToLand',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
                  ('order', models.FloatField(default=0.0)),
              ],
              options={
                  'ordering': ('order',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='ProjectManagerRequestStatus',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='FDISICGrouping',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'verbose_name': 'FDI SIC Grouping',
              },
          ),
          migrations.CreateModel(
              name='InvestmentSector',
              fields=[
                  ('sector', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, primary_key=True, serialize=False, to='metadata.Sector')),
                  ('fdi_sic_grouping', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='investment_sectors', to='investment.FDISICGrouping')),
              ],
          ),
          migrations.CreateModel(
              name='GVAMultiplier',
              fields=[
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('multiplier', models.DecimalField(decimal_places=6, max_digits=7)),
                  ('financial_year', models.IntegerField(help_text='The year from which the gva multiplier should apply from.')),
                  ('fdi_sic_grouping', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='gva_multipliers', to='investment.FDISICGrouping')),
              ],
              options={
                  'verbose_name': 'GVA Multiplier',
                  'unique_together': {('fdi_sic_grouping', 'financial_year')},
              },
          ),
          migrations.CreateModel(
              name='InvestmentProject',
              fields=[
                  ('created_on', models.DateTimeField(auto_now_add=True, db_index=True, null=True)),
                  ('modified_on', models.DateTimeField(auto_now=True, null=True)),
                  ('name', models.CharField(max_length=255)),
                  ('description', models.TextField()),
                  ('estimated_land_date', models.DateField(blank=True, null=True)),
                  ('cdms_project_code', models.CharField(blank=True, max_length=255, null=True)),
                  ('referral_source_activity_event', models.CharField(blank=True, max_length=255, null=True)),
                  ('client_cannot_provide_total_investment', models.BooleanField(null=True)),
                  ('total_investment', models.DecimalField(blank=True, decimal_places=0, max_digits=19, null=True)),
                  ('client_cannot_provide_foreign_investment', models.BooleanField(null=True)),
                  ('foreign_equity_investment', models.DecimalField(blank=True, decimal_places=0, max_digits=19, null=True)),
                  ('government_assistance', models.BooleanField(null=True)),
                  ('number_new_jobs', models.IntegerField(blank=True, null=True)),
                  ('number_safeguarded_jobs', models.IntegerField(blank=True, null=True)),
                  ('r_and_d_budget', models.BooleanField(null=True)),
                  ('non_fdi_r_and_d_budget', models.BooleanField(null=True, verbose_name='has associated non-FDI R&D project')),
                  ('new_tech_to_uk', models.BooleanField(null=True)),
                  ('export_revenue', models.BooleanField(null=True)),
                  ('client_requirements', models.TextField(blank=True, null=True)),
                  ('site_decided', models.BooleanField(null=True)),
                  ('address_1', models.CharField(blank=True, max_length=255, null=True)),
                  ('address_2', models.CharField(blank=True, max_length=255, null=True)),
                  ('address_town', models.CharField(blank=True, max_length=255, null=True)),
                  ('address_postcode', models.CharField(blank=True, max_length=255, null=True)),
                  ('client_considering_other_countries', models.BooleanField(null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('average_salary', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='metadata.SalaryRange')),
                  ('business_activities', models.ManyToManyField(blank=True, related_name='_investmentproject_business_activities_+', to='metadata.InvestmentBusinessActivity')),
                  ('client_contacts', models.ManyToManyField(blank=True, related_name='investment_projects', to='company.Contact')),
                  ('client_relationship_manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to=settings.AUTH_USER_MODEL)),
                  ('competitor_countries', models.ManyToManyField(blank=True, related_name='_investmentproject_competitor_countries_+', to='metadata.Country')),
                  ('fdi_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to='metadata.FDIType')),
                  ('intermediate_company', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='intermediate_investment_projects', to='company.Company')),
                  ('investment_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='investment_projects', to='metadata.InvestmentType')),
                  ('investor_company', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='investor_investment_projects', to='company.Company')),
                  ('stage', models.ForeignKey(default='8a320cc9-ae2e-443e-9d26-2f36452c2ced', on_delete=django.db.models.deletion.PROTECT, related_name='investment_projects', to='metadata.InvestmentProjectStage')),
                  ('project_assurance_adviser', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('project_manager', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('referral_source_activity', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to='metadata.ReferralSourceActivity')),
                  ('referral_source_activity_marketing', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to='metadata.ReferralSourceMarketing')),
                  ('referral_source_activity_website', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to='metadata.ReferralSourceWebsite')),
                  ('referral_source_adviser', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='referred_investment_projects', to=settings.AUTH_USER_MODEL)),
                  ('sector', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='metadata.Sector')),
                  ('strategic_drivers', models.ManyToManyField(blank=True, related_name='investment_projects', to='metadata.InvestmentStrategicDriver')),
                  ('uk_company', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investee_projects', to='company.Company')),
                  ('uk_region_locations', models.ManyToManyField(blank=True, related_name='_investmentproject_uk_region_locations_+', to='metadata.UKRegion', verbose_name='possible UK regions')),
                  ('archived', models.BooleanField(default=False)),
                  ('archived_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('archived_on', models.DateTimeField(blank=True, null=True)),
                  ('archived_reason', models.TextField(blank=True, null=True)),
                  ('actual_land_date', models.DateField(blank=True, null=True)),
                  ('approved_commitment_to_invest', models.BooleanField(null=True)),
                  ('approved_fdi', models.BooleanField(null=True)),
                  ('approved_good_value', models.BooleanField(null=True)),
                  ('approved_high_value', models.BooleanField(null=True)),
                  ('approved_landed', models.BooleanField(null=True)),
                  ('approved_non_fdi', models.BooleanField(null=True)),
                  ('priority', models.CharField(blank=True, choices=[('1_low', 'Low'), ('2_medium', 'Medium'), ('3_high', 'High')], max_length=255, null=True)),
                  ('fdi_value', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='investment_projects', to='metadata.FDIValue')),
                  ('some_new_jobs', models.BooleanField(null=True)),
                  ('uk_company_decided', models.BooleanField(null=True)),
                  ('will_new_jobs_last_two_years', models.BooleanField(null=True)),
                  ('quotable_as_public_case_study', models.BooleanField(null=True)),
                  ('other_business_activity', models.CharField(blank=True, max_length=255, null=True)),
                  ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('country_lost_to', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='metadata.Country')),
                  ('date_abandoned', models.DateField(blank=True, null=True)),
                  ('date_lost', models.DateField(blank=True, null=True)),
                  ('reason_abandoned', models.TextField(blank=True, null=True)),
                  ('reason_delayed', models.TextField(blank=True, null=True)),
                  ('reason_lost', models.TextField(blank=True, null=True)),
                  ('status', models.CharField(choices=[('ongoing', 'Ongoing'), ('delayed', 'Delayed'), ('dormant', 'Dormant'), ('lost', 'Lost'), ('abandoned', 'Abandoned'), ('won', 'Won')], default='ongoing', max_length=255)),
                  ('anonymous_description', models.TextField(blank=True)),
                  ('associated_non_fdi_r_and_d_project', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.InvestmentProject', verbose_name='associated non-FDI R&D project')),
                  ('investor_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.InvestorType')),
                  ('level_of_involvement', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.Involvement')),
                  ('specific_programme', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.SpecificProgramme')),
                  ('archived_documents_url_path', models.CharField(blank=True, help_text='Legacy field. File browser path to the archived documents for this investment project.', max_length=255)),
                  ('comments', models.TextField(blank=True)),
                  ('actual_uk_regions', models.ManyToManyField(blank=True, related_name='_investmentproject_actual_uk_regions_+', to='metadata.UKRegion', verbose_name='actual UK regions')),
                  ('allow_blank_estimated_land_date', models.BooleanField(default=False, help_text='Controls whether estimated land date is a required field. Intended for projects migrated from CDMS in the verify win and won stages where legacy data for estimated land date does not exist.')),
                  ('allow_blank_possible_uk_regions', models.BooleanField(default=False, help_text='Controls whether possible UK regions is a required field (after the prospect stage). Intended for projects migrated from CDMS in the verify win and won stages where legacy data for possible UK regions does not exist.')),
                  ('delivery_partners', models.ManyToManyField(blank=True, help_text='These are the delivery partner(s) in the region(s) where the project landed.', related_name='_investmentproject_delivery_partners_+', to='investment.InvestmentDeliveryPartner', verbose_name='investment delivery partners')),
                  ('project_arrived_in_triage_on', models.DateField(blank=True, null=True)),
                  ('proposal_deadline', models.DateField(blank=True, null=True)),
                  ('project_manager_first_assigned_on', models.DateTimeField(blank=True, null=True)),
                  ('project_manager_first_assigned_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('country_investment_originates_from', models.ForeignKey(blank=True, help_text='The country from which the investment originates', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='metadata.Country')),
                  ('likelihood_to_land', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.LikelihoodToLand')),
                  ('project_manager_requested_on', models.DateTimeField(blank=True, null=True)),
                  ('project_manager_request_status', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='investment.ProjectManagerRequestStatus')),
                  ('gva_multiplier', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='investment_projects', to='investment.GVAMultiplier')),
                  ('gross_value_added', models.DecimalField(blank=True, decimal_places=0, help_text='Denormalised GVA value which is automatically populated using the gva multiplier and the foreign equity investment value.', max_digits=25, null=True)),
              ],
              options={
                  'abstract': False,
                  'permissions': (('view_associated_investmentproject', 'Can view associated investment project'), ('change_associated_investmentproject', 'Can change associated investment project'), ('export_investmentproject', 'Can export investment project'), ('view_investmentproject_document', 'Can view investment project document'), ('change_stage_to_won_investmentproject', 'Can change investment project stage to won')),
                  'default_permissions': ('add', 'change_all', 'delete', 'view_all'),
              },
          ),
          migrations.CreateModel(
              name='InvestmentProjectCode',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('project', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='investment.InvestmentProject')),
              ],
          ),
          migrations.CreateModel(
              name='InvestmentProjectStageLog',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('created_on', models.DateTimeField()),
                  ('investment_project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stage_log', to='investment.InvestmentProject')),
                  ('stage', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='metadata.InvestmentProjectStage')),
              ],
              options={
                  'ordering': ('created_on',),
              },
          ),
          migrations.CreateModel(
              name='InvestmentProjectTeamMember',
              fields=[
                  ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                  ('role', models.CharField(max_length=255)),
                  ('adviser', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('investment_project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='team_members', to='investment.InvestmentProject')),
              ],
              options={
                  'unique_together': {('investment_project', 'adviser')},
                  'default_permissions': (),
              },
          ),
          migrations.CreateModel(
              name='InvestmentActivityType',
              fields=[
                  ('disabled_on', models.DateTimeField(blank=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('name', models.TextField(blank=True)),
              ],
              options={
                  'ordering': ('name',),
                  'abstract': False,
              },
          ),
          migrations.CreateModel(
              name='InvestmentActivity',
              fields=[
                  ('created_on', models.DateTimeField(auto_now_add=True, db_index=True, null=True)),
                  ('modified_on', models.DateTimeField(auto_now=True, null=True)),
                  ('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
                  ('text', models.TextField()),
                  ('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('investment_project', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='activities', to='investment.InvestmentProject')),
                  ('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to=settings.AUTH_USER_MODEL)),
                  ('activity_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='+', to='investment.InvestmentActivityType')),
                  ('revision', models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='reversion.Revision')),
              ],
              options={
                  'ordering': ('-created_on',),
              },
          ),
          migrations.AddIndex(
              model_name='investmentproject',
              index=models.Index(fields=['created_on', 'id'], name='investment__created_b91445_idx'),
          ),
          migrations.RunPython(
              code=load_fixtures,
              reverse_code=django.db.migrations.operations.special.RunPython.noop,
          ),
      ]
  