30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
# this file derive from django-tenant-schemas
|
|
# Author: Bernardo Pires Carneiro
|
|
# Email: carneiro.be@gmail.com
|
|
# License: MIT license
|
|
# Home-page: http://github.com/bcarneiro/django-tenant-schemas
|
|
from django.conf import settings
|
|
from django.core.management.base import CommandError
|
|
from tenant_schemas.utils import django_is_in_test_mode
|
|
|
|
if 'south' in settings.INSTALLED_APPS:
|
|
from south.management.commands import syncdb
|
|
else:
|
|
from django.core.management.commands import syncdb
|
|
|
|
|
|
class Command(syncdb.Command):
|
|
def handle(self, *args, **options):
|
|
database = options.get('database', 'default')
|
|
if (
|
|
settings.DATABASES[database]['ENGINE'] == 'tenant_schemas.postgresql_backend'
|
|
and not django_is_in_test_mode()
|
|
):
|
|
raise CommandError(
|
|
"syncdb has been disabled, for database '{}'. "
|
|
"Use sync_schemas instead. Please read the "
|
|
"documentation if you don't know why "
|
|
"you shouldn't call syncdb directly!".format(database)
|
|
)
|
|
super().handle(*args, **options)
|