# Generated by Django 2.1.7 on 2019-07-10 21:31

from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.core.management import call_command
from project.models import ProjectType
import os

def load_fixture(apps, schema_editor):
    project_types_fixtures = os.path.join(settings.BASE_DIR, 'project',
                                          'fixtures', 'project-types.json')
    call_command('loaddata', project_types_fixtures) 

def unload_fixture(apps, schema_editor):
    ProjectType.objects.all().delete()

class Migration(migrations.Migration):

    dependencies = [
        ('project', '0031_auto_20190826_1305'),
    ]

    operations = [
        migrations.CreateModel(
            name='ProjectType',
            fields=[
                ('id', models.PositiveSmallIntegerField(primary_key=True, serialize=False)),
                ('name', models.CharField(max_length=20)),
                ('description', models.TextField()),
            ],
        ),
        migrations.RunPython(load_fixture, reverse_code=unload_fixture),
        migrations.AlterField(
            model_name='activeproject',
            name='resource_type',
            field=models.ForeignKey(db_column='resource_type', on_delete=django.db.models.deletion.PROTECT, related_name='activeprojects', to='project.ProjectType'),
        ),
        migrations.AlterField(
            model_name='archivedproject',
            name='resource_type',
            field=models.ForeignKey(db_column='resource_type', on_delete=django.db.models.deletion.PROTECT, related_name='archivedprojects', to='project.ProjectType'),
        ),
        migrations.AlterField(
            model_name='publishedproject',
            name='resource_type',
            field=models.ForeignKey(db_column='resource_type', on_delete=django.db.models.deletion.PROTECT, related_name='publishedprojects', to='project.ProjectType'),
        ),
    ]
