# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2017-07-18 12:11
from __future__ import unicode_literals

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


def preset_issue_status(apps, schema_editor):
    status_arr = ['新增问题', '问题处理中', '问题关闭']
    type_model = apps.get_model('issue', 'issuestatus')
    for status in status_arr:
        type_model.objects.get_or_create(name=status)


class Migration(migrations.Migration):

    dependencies = [
        ('common', '0005_auto_20170629_1517'),
        ('issue', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='IssueStatus',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('created_time', models.DateTimeField(auto_now_add=True)),
                ('updated_time', models.DateTimeField(auto_now=True)),
                ('name', models.CharField(max_length=256, verbose_name='状态名称')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.RunPython(preset_issue_status),
        migrations.AddField(
            model_name='issue',
            name='app_module',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='common.AppModule'),
        ),
        migrations.AlterField(
            model_name='issue',
            name='score',
            field=models.IntegerField(blank=True, default=0, null=True),
        ),
        migrations.AddField(
            model_name='issue',
            name='status',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='issue.IssueStatus'),
            preserve_default=False,
        ),
    ]
