Files
edx-platform/common/djangoapps/embargo/migrations/0002_data__add_countries.py
Kevin Falcone 2d9708da03 Remove uses of using() from migrations
This hardcoded the db_alias fetched from schema_editor and forces django
to try and migrate any second database you use, rather than routing to
the default database.  In testing a build from scratch, these do not
appear needed.

Using using() prevents us from using multiple databases behind edxapp.

Additionally - add back a removed backwards migration from certificates
0003.  I have no idea why this was dropped in the 1.8 upgrade.
2016-02-01 16:57:26 -05:00

31 lines
925 B
Python

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Converted from the original South migration 0003_add_countries.py
from django.db import migrations, models
from django_countries import countries
def create_embargo_countries(apps, schema_editor):
"""Populate the available countries with all 2-character ISO country codes. """
country_model = apps.get_model("embargo", "Country")
for country_code, __ in list(countries):
country_model.objects.get_or_create(country=country_code)
def remove_embargo_countries(apps, schema_editor):
"""Clear all available countries. """
country_model = apps.get_model("embargo", "Country")
country_model.objects.all().delete()
class Migration(migrations.Migration):
dependencies = [
('embargo', '0001_initial'),
]
operations = [
migrations.RunPython(create_embargo_countries, remove_embargo_countries),
]