# Generated by Django 2.1 on 2018-09-13 02:29

from django.db import migrations


def forward(apps, schema_editor):
    Producer = apps.get_model('producer', 'Producer')
    Product = apps.get_model('producer', 'Product')

    # create placeholder producer
    producer = Producer.objects.create(name='Placeholder', slug='placeholder')

    # set the producer on all existing products
    Product.objects.update(producer=producer)


def backward(apps, schema_editor):
    Product = apps.get_model('producer', 'Product')

    # remove the producer from all existing products
    Product.objects.update(producer=None)


class Migration(migrations.Migration):

    dependencies = [
        ('producer', '0002_auto_20180913_0229'),
    ]

    operations = [
        migrations.RunPython(forward, backward)
    ]
