From 0f8444c055bbb6a97810aab6e01ced5a784e2926 Mon Sep 17 00:00:00 2001 From: John Giannelos Date: Fri, 31 Mar 2017 17:20:06 +0200 Subject: [PATCH] [Bug 1351853] Fix `Netherlands` geo_country migration. --- .../migrations/0016_auto_20170331_0812.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 mozillians/users/migrations/0016_auto_20170331_0812.py diff --git a/mozillians/users/migrations/0016_auto_20170331_0812.py b/mozillians/users/migrations/0016_auto_20170331_0812.py new file mode 100644 index 000000000..d8e217dd2 --- /dev/null +++ b/mozillians/users/migrations/0016_auto_20170331_0812.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +def migrate_countries(apps, schema_editor): + Country = apps.get_model('cities_light', 'Country') + UserProfile = apps.get_model('users', 'UserProfile') + + try: + qs = UserProfile.objects.filter(geo_country__name='Netherlands') + country = Country.objects.get(name='Netherlands') + kwargs = { + 'country': country, + } + qs.update(**kwargs) + except: + pass + + +def backwards(apps, schema_editor): + pass + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0015_auto_20170323_1202'), + ] + + operations = [ + migrations.RunPython(migrate_countries, backwards), + ]