# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2018-08-05 23:35
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

    dependencies = [
        ('crm', '0006_auto_20180802_0712'),
    ]

    operations = [
        migrations.CreateModel(
            name='PersonState',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('description', models.TextField(blank=True, default='')),
            ],
        ),
        migrations.AddField(
            model_name='person',
            name='state',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='crm.PersonState'),
            preserve_default=False,
        ),
    ]

# -*- coding: utf-8 -*-
# Generated by Django 1.11.1 on 2018-08-05 23:35
from __future__ import unicode_literals

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

def create_default_state(apps, schema_editor):
    PersonState = apps.get_model('crm', 'PersonState')
    PersonState.objects.get_or_create(pk=1, defaults={'name': 'Default'})

class Migration(migrations.Migration):

    dependencies = [
        ('crm', '0006_auto_20180802_0712'),
    ]

    operations = [
        migrations.CreateModel(
            name='PersonState',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=200)),
                ('description', models.TextField(blank=True, default='')),
            ],
        ),
        migrations.RunPython(create_default_state),
        migrations.AddField(
            model_name='person',
            name='state',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='crm.PersonState'),
            preserve_default=False,
        ),
    ]

fix broken migration by creating default PersonState on migrate