Created
December 11, 2015 19:31
-
-
Save samirbr/bfce82775762bc6d4c88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import migrations, models | |
def update_plans(apps, schema_editor): | |
# free to Free | |
for user in User.objects.filter(plan='free'): | |
user.plan = 'Free' | |
user.save() | |
# premium to Monthly | |
for user in User.objects.filter(plan='premium'): | |
user.plan = 'Monthly' | |
user.save() | |
# default to OnDemand | |
for user in User.objects.filter(plan='default'): | |
user.plan = 'OnDemand' | |
user.save() | |
def noop(apps, schema_editor): | |
pass | |
# manage.py makemigrations --empty user | |
class Migration(migrations.Migration): | |
# ... | |
operations = [ | |
migrations.RunPython(update_plans, noop), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment