Projet

Général

Profil

Télécharger (1,12 ko) Statistiques
| Branche: | Tag: | Révision:

root / entrouvert / djommon / multitenant / management / commands / migrate.py @ 1db4b242

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
import django
7
from django.conf import settings
8
from django.core.management.base import CommandError, BaseCommand
9

    
10
if django.VERSION < (1, 7, 0):
11
    try:
12
        from south.management.commands.migrate import Command as MigrateCommand
13
    except ImportError:
14
        MigrateCommand = BaseCommand
15
else:
16
    MigrateCommand = BaseCommand
17

    
18
class Command(MigrateCommand):
19

    
20
    def handle(self, *args, **options):
21
        database = options.get('database', 'default')
22
        if (settings.DATABASES[database]['ENGINE'] == 'tenant_schemas.postgresql_backend' or
23
                MigrateCommand is BaseCommand):
24
            raise CommandError("migrate has been disabled, for database '{}'. Use migrate_schemas "
25
                               "instead. Please read the documentation if you don't know why you "
26
                               "shouldn't call migrate directly!".format(database))
27
        super(Command, self).handle(*args, **options)
(7-7/12)