From c54dcd07d91bd66c22085417e095aea771be7e94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laura=20Kl=C3=BCnder?= Date: Tue, 30 Aug 2016 16:05:35 +0200 Subject: [PATCH] make sure that the commands are operating in the right database --- src/c3nav/mapdata/management/commands/checkmap.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/c3nav/mapdata/management/commands/checkmap.py b/src/c3nav/mapdata/management/commands/checkmap.py index ed1d03c8..8ab6e45f 100644 --- a/src/c3nav/mapdata/management/commands/checkmap.py +++ b/src/c3nav/mapdata/management/commands/checkmap.py @@ -3,7 +3,7 @@ import tempfile from django.core.management import call_command from django.core.management.base import BaseCommand -from django.db import connections +from django.db import connections, router class Command(BaseCommand): @@ -22,6 +22,12 @@ class Command(BaseCommand): 'NAME': tmp, } + # This is not nice, but the easiest way + def tmpdb(*args, **kwargs): + return 'tmpdb' + router.db_for_read = tmpdb + router.db_for_write = tmpdb + try: call_command('migrate', database='tmpdb') call_command('loadmap', yes=True)