1
|
# this file derive from django-tenant-schemas
|
2
|
# Author: Bernardo Pires Carneiro
|
3
|
# Email: carneiro.be@gmail.com
|
4
|
# License: MIT license
|
5
|
# Home-page: http://github.com/bcarneiro/django-tenant-schemas
|
6
|
from django.core.management.base import CommandError
|
7
|
from django.conf import settings
|
8
|
from tenant_schemas.utils import django_is_in_test_mode
|
9
|
|
10
|
if 'south' in settings.INSTALLED_APPS:
|
11
|
from south.management.commands import syncdb
|
12
|
else:
|
13
|
from django.core.management.commands import syncdb
|
14
|
|
15
|
|
16
|
class Command(syncdb.Command):
|
17
|
|
18
|
def handle(self, *args, **options):
|
19
|
database = options.get('database', 'default')
|
20
|
if (settings.DATABASES[database]['ENGINE'] == 'tenant_schemas.postgresql_backend' and not
|
21
|
django_is_in_test_mode()):
|
22
|
raise CommandError("syncdb has been disabled, for database '{0}'. "
|
23
|
"Use sync_schemas instead. Please read the "
|
24
|
"documentation if you don't know why "
|
25
|
"you shouldn't call syncdb directly!".format(database))
|
26
|
super(Command, self).handle(*args, **options)
|