# -*- coding: utf-8 -*-
# Generated by Django 1.11.22 on 2019-07-16 06:38


from django.db import migrations

from ecommerce.core.constants import ORDER_MANAGER_ROLE


def create_roles(apps, schema_editor):
    """Create the ecommerce roles if they do not already exist."""
    EcommerceFeatureRole = apps.get_model('core', 'EcommerceFeatureRole')
    EcommerceFeatureRole.objects.update_or_create(name=ORDER_MANAGER_ROLE)


def delete_roles(apps, schema_editor):
    """Delete the ecommerce roles."""
    EcommerceFeatureRole = apps.get_model('core', 'EcommerceFeatureRole')
    EcommerceFeatureRole.objects.filter(name=ORDER_MANAGER_ROLE).delete()


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0054_auto_20190626_0153'),
    ]

    operations = [
        migrations.RunPython(create_roles, delete_roles)
    ]
