Commit 6b819174 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 50ad9b5f
...@@ -9,9 +9,8 @@ from milestones.data import fetch_milestone_relationship_types ...@@ -9,9 +9,8 @@ from milestones.data import fetch_milestone_relationship_types
def seed_relationship_types(apps, schema_editor): def seed_relationship_types(apps, schema_editor):
"""Seed the relationship types.""" """Seed the relationship types."""
MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType") MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType")
db_alias = schema_editor.connection.alias
for name in fetch_milestone_relationship_types().values(): for name in fetch_milestone_relationship_types().values():
MilestoneRelationshipType.objects.using(db_alias).get_or_create( MilestoneRelationshipType.objects.get_or_create(
name=name, name=name,
description='Autogenerated milestone relationship type "{}"'.format(name), description='Autogenerated milestone relationship type "{}"'.format(name),
) )
...@@ -20,9 +19,8 @@ def seed_relationship_types(apps, schema_editor): ...@@ -20,9 +19,8 @@ def seed_relationship_types(apps, schema_editor):
def delete_relationship_types(apps, schema_editor): def delete_relationship_types(apps, schema_editor):
"""Clean up any relationships we made.""" """Clean up any relationships we made."""
MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType") MilestoneRelationshipType = apps.get_model("milestones", "MilestoneRelationshipType")
db_alias = schema_editor.connection.alias
for name in fetch_milestone_relationship_types().values(): for name in fetch_milestone_relationship_types().values():
MilestoneRelationshipType.objects.using(db_alias).filter(name=name).delete() MilestoneRelationshipType.objects.filter(name=name).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