# -*- coding: utf-8 -*-
# Generated by Django 1.11.17 on 2019-01-02 03:49
from __future__ import unicode_literals

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


def get_or_create_branch(apps, schema_editor):
    Branch = apps.get_model('account_keeping', 'Branch')
    if Branch.objects.count() == 0:
        Branch.objects.create(name="Main", slug="main")


class Migration(migrations.Migration):

    dependencies = [
        ('account_keeping', '0004_branch'),
    ]

    operations = [
        migrations.RunPython(get_or_create_branch),
        migrations.AddField(
            model_name='account',
            name='branch',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='accounts', to='account_keeping.Branch', verbose_name='Branch'),
            preserve_default=False,
        ),
        migrations.AddField(
            model_name='invoice',
            name='branch',
            field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='invoices', to='account_keeping.Branch', verbose_name='Branch'),
            preserve_default=False,
        ),
    ]
