Commit 6b7fe344 by Kevin Falcone

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.
parent bebda677
...@@ -16,16 +16,14 @@ DEFAULT_PROFILES = [ ...@@ -16,16 +16,14 @@ DEFAULT_PROFILES = [
def create_default_profiles(apps, schema_editor): def create_default_profiles(apps, schema_editor):
""" Add default profiles """ """ Add default profiles """
Profile = apps.get_model("edxval", "Profile") Profile = apps.get_model("edxval", "Profile")
db_alias = schema_editor.connection.alias
for profile in DEFAULT_PROFILES: for profile in DEFAULT_PROFILES:
Profile.objects.using(db_alias).get_or_create(profile_name=profile) Profile.objects.get_or_create(profile_name=profile)
def delete_default_profiles(apps, schema_editor): def delete_default_profiles(apps, schema_editor):
""" Remove default profiles """ """ Remove default profiles """
Profile = apps.get_model("edxval", "Profile") Profile = apps.get_model("edxval", "Profile")
db_alias = schema_editor.connection.alias Profile.objects.filter(profile_name__in=DEFAULT_PROFILES).delete()
Profile.objects.using(db_alias).filter(profile_name__in=DEFAULT_PROFILES).delete()
class Migration(migrations.Migration): class Migration(migrations.Migration):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment