feat: add CRMDatabaseRouter for multi-database routing across apps and models
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 33s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 33s
This commit is contained in:
parent
9da19d2daf
commit
0261439af1
1 changed files with 4 additions and 1 deletions
|
|
@ -25,6 +25,9 @@ class CRMDatabaseRouter:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
def allow_migrate(self, db, app_label, model_name=None, **hints):
|
||||||
|
if app_label in ['auth', 'contenttypes', 'admin', 'sessions', 'crm']:
|
||||||
|
return db == 'default'
|
||||||
|
|
||||||
if app_label == 'seller_models':
|
if app_label == 'seller_models':
|
||||||
if model_name == 'product':
|
if model_name == 'product':
|
||||||
return db == 'product_db'
|
return db == 'product_db'
|
||||||
|
|
@ -36,4 +39,4 @@ class CRMDatabaseRouter:
|
||||||
|
|
||||||
if db in ['seller_db', 'product_db', 'customer_db']:
|
if db in ['seller_db', 'product_db', 'customer_db']:
|
||||||
return False
|
return False
|
||||||
return True
|
return db == 'default'
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue