31 lines
1.1 KiB
Python
31 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
|
|
import django
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand, CommandError
|
|
from tenant_schemas.utils import django_is_in_test_mode
|
|
|
|
|
|
class Command(BaseCommand):
|
|
def handle(self, *args, **options):
|
|
database = options.get('database', 'default')
|
|
if (
|
|
settings.DATABASES[database]['ENGINE'] == 'tenant_schemas.postgresql_backend'
|
|
or MigrateCommand is BaseCommand
|
|
):
|
|
raise CommandError(
|
|
"migrate has been disabled, for database '{}'. Use migrate_schemas "
|
|
"instead. Please read the documentation if you don't know why you "
|
|
"shouldn't call migrate directly!".format(database)
|
|
)
|
|
super().handle(*args, **options)
|
|
|
|
|
|
if django_is_in_test_mode():
|
|
from .migrate_schemas import MigrateSchemasCommand
|
|
|
|
Command = MigrateSchemasCommand
|