# Generated by Django 2.2 on 2019-06-23 08:46

from django.db import migrations


def add_keys(apps, schema_editor):
    '''
    We can't import the Post model directly as it may be a newer
    version than this migration expects. We use the historical version.
    '''
    Setting = apps.get_model('settings', 'Setting')
    key = ''
    try:
        key = 'USER_REGISTER_GIFT_BON_CREDITS'
        Setting.objects.get(key=key)
    except Exception:
        Setting.objects.create(
            title='شارژ هدیه برای ثبت نام کاربر جدید',
            key=key,
            value='0',
            value_type='i',
            is_show=False,
            is_variable_in_home=False,
        )


def remove_keys(apps, schema_editor):
    '''
    We can't import the Post model directly as it may be a newer
    version than this migration expects. We use the historical version.
    '''
    Setting = apps.get_model('settings', 'Setting')
    try:
        key = 'USER_REGISTER_GIFT_BON_CREDITS'
        Setting.objects.get(key=key).delete()
    except Exception:
        pass


class Migration(migrations.Migration):

    dependencies = [
        ('settings', '0019_auto_20190525_1158'),
    ]

    operations = [
        migrations.RunPython(add_keys, reverse_code=remove_keys),
    ]
