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.
This commit is contained in:
@@ -10,15 +10,13 @@ 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")
|
||||
db_alias = schema_editor.connection.alias
|
||||
for country_code, __ in list(countries):
|
||||
country_model.objects.using(db_alias).get_or_create(country=country_code)
|
||||
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")
|
||||
db_alias = schema_editor.connection.alias
|
||||
country_model.objects.using(db_alias).all().delete()
|
||||
country_model.objects.all().delete()
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user