Database access in data migrations defaults to the 'default' database. Force it to the user selected database instead.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-19 20:53:04 -04:00
parent fdfa4755e9
commit eda8d18146
13 changed files with 31 additions and 26 deletions

View File

@@ -21,9 +21,9 @@ def migrate_old_comments(apps, schema_editor):
Document = apps.get_model('documents', 'Document')
User = apps.get_model(*settings.AUTH_USER_MODEL.split('.'))
for old_comment in OldComment.objects.all():
for old_comment in OldComment.objects.using(schema_editor.connection.alias).all():
comment = Comment(
document=Document.objects.get(pk=old_comment.object_pk),
document=Document.objects.using(schema_editor.connection.alias).get(pk=old_comment.object_pk),
user=User(old_comment.user.pk),
comment=old_comment.comment,
submit_date=old_comment.submit_date,