# -*- coding: utf-8 -*-
# Generated by Django 1.9.12 on 2017-04-05 06:49
from __future__ import unicode_literals

from django.db import migrations, models


def forwards(apps, schema_editor):
    CartItem = apps.get_model('shopit', 'CartItem')
    for item in CartItem.objects.all():
        item.product_code = item.extra.get('product_code', '')
        item.save()


def backwards(apps, schema_editor):
    CartItem = apps.get_model('shopit', 'CartItem')
    for item in CartItem.objects.all():
        item.extra['product_code'] = item.product_code
        item.save()


class Migration(migrations.Migration):

    dependencies = [
        ('shopit', '0004_add_description_to_categorization'),
    ]

    operations = [
        migrations.AddField(
            model_name='cartitem',
            name='product_code',
            field=models.CharField(blank=True, help_text='Product code of added item.', max_length=255, null=True, verbose_name='Product code'),
        ),
        migrations.AlterField(
            model_name='billingaddress',
            name='priority',
            field=models.SmallIntegerField(db_index=True, default=0, help_text='Priority for using this address'),
        ),
        migrations.AlterField(
            model_name='shippingaddress',
            name='priority',
            field=models.SmallIntegerField(db_index=True, default=0, help_text='Priority for using this address'),
        ),
        migrations.RunPython(forwards, reverse_code=backwards),
    ]
