0010_rename_partner_category.py 903 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from django.db import migrations


def forwards_func(apps, schema_editor):
    category = apps.get_model("pushnotifications", "Category")
    db_alias = schema_editor.connection.alias

    category.objects.using(db_alias).get(key='sponsor').delete()
    category.objects.create(
        key='partner',
        name_nl='Partners',
        name_en='Partners',
    )


def reverse_func(apps, schema_editor):
    category = apps.get_model("pushnotifications", "Category")
    db_alias = schema_editor.connection.alias

    category.objects.using(db_alias).get(key='partner').delete()
    category.objects.create(
        key='sponsor',
        name_nl='Sponsor',
        name_en='Sponsor',
    )


class Migration(migrations.Migration):

    dependencies = [
        ('pushnotifications', '0009_rename_categories'),
    ]

    operations = [
        migrations.RunPython(forwards_func, reverse_func),
    ]