2016-12-08 10 views

答えて

0

あなたはすべてのスキーマのを反復処理したい場合は、すべてのテナント

./manage.py tenant_command flush --schema=customer1 

ソースを反復するカスタムコマンドを作成する必要があります、tenant_commandラッパーを使用してスキーマごとのベースで任意のDjangoのコマンドを使用することができます:http://django-tenant-schemas.readthedocs.io/en/latest/use.html#tenant-command

+1

なぜdownvote .. ??私が理解できる限り、彼はどのようにDBをフラッシュするかについて尋ねています。ありがとう。 –

0

私はhttps://github.com/tomturner/django-tenantsで作業していますが、これはhttps://github.com/bernardopires/django-tenant-schemasでも有効です。

複数のテナント/スキーマを使用する場合、フラッシュはもはや機能しません。 manage.py flushを使用すると、満たされていない外部キー制約があることを示すエラーが表示されます。それが示唆:

from django.core.management import call_command 
from django.core.management.commands.flush import Command as FlushCommand 
from django.db import transaction 

class Command(FlushCommand):  
    @transaction.atomic 
    def handle(self, *args, **options): 
     options['allow_cascade'] = True 
     call_command('flush', *args, **options) 

DjangoのデフォルトflushコマンドのみデータベースにTRUNCATEを送信します。ここでは

HINT: Truncate table "<your table name>" at the same time, or use TRUNCATE ... CASCADE. 

は(私だけPostgreSQL`でテスト)があることない管理コマンド(flush_cascade.py)でありますCASCADEは追加されません。すべてのデータベースバックエンドがカスケード文をサポートするわけではないためです。

関連する問題