Error checking in profile migration.

This commit is contained in:
Samuel Clay 2012-03-20 21:33:06 -07:00
parent bd784e85e4
commit 362459a3f9

View file

@ -6,6 +6,7 @@ from south.v2 import DataMigration
from django.db import models
from django.contrib.auth.models import User
from apps.social.models import MSocialProfile
from mongoengine.queryset import OperationError
class Migration(DataMigration):
@ -14,8 +15,11 @@ class Migration(DataMigration):
user = User.objects.create(username='popular', email='popular@newsblur.com')
user.set_password("%s-%s" % (random.random(), random.random()))
user.save()
profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
profile.save()
try:
profile, _ = MSocialProfile.objects.get_or_create(user_id=user.pk)
profile.save()
except OperationError:
print " ---> Whoops, already have a popular user."
def backwards(self, orm):
"Write your backwards methods here."