feat(spip): connecte la db spip
This commit is contained in:
parent
a69c9d2549
commit
0e08c4446e
|
@ -2,6 +2,8 @@ class Drupal2SPIPRouter:
|
||||||
def db_for_read(self, model, **hints):
|
def db_for_read(self, model, **hints):
|
||||||
if model._meta.app_label == 'drupal':
|
if model._meta.app_label == 'drupal':
|
||||||
return 'drupal'
|
return 'drupal'
|
||||||
|
if model._meta.app_label == 'spip':
|
||||||
|
return 'spip'
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def db_for_write(self, model, **hints):
|
def db_for_write(self, model, **hints):
|
||||||
|
@ -12,7 +14,7 @@ class Drupal2SPIPRouter:
|
||||||
We disallow cross db relations.
|
We disallow cross db relations.
|
||||||
"""
|
"""
|
||||||
app1, app2 = obj1._meta.app_label, obj2._meta.app_label
|
app1, app2 = obj1._meta.app_label, obj2._meta.app_label
|
||||||
if 'drupal' in [app1, app2]:
|
if 'drupal' in [app1, app2] or 'spip' in [app1, app2]:
|
||||||
return app1 == app2
|
return app1 == app2
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -20,6 +22,6 @@ class Drupal2SPIPRouter:
|
||||||
"""
|
"""
|
||||||
We disallow migrations for those db.
|
We disallow migrations for those db.
|
||||||
"""
|
"""
|
||||||
if db == 'drupal':
|
if db in ['drupal', 'spip']:
|
||||||
return False
|
return False
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -60,6 +60,10 @@ DATABASES = {
|
||||||
'DRUPAL_DATABASE_URL',
|
'DRUPAL_DATABASE_URL',
|
||||||
default='sqlite:///{}'.format(base_dir('drupal.db')),
|
default='sqlite:///{}'.format(base_dir('drupal.db')),
|
||||||
),
|
),
|
||||||
|
'spip': env.db_url(
|
||||||
|
'SPIP_DATABASE_URL',
|
||||||
|
default='sqlite:///{}'.format(base_dir('spip.db')),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
DATABASE_ROUTERS = ['drupal2spip_lal.base.routers.Drupal2SPIPRouter']
|
DATABASE_ROUTERS = ['drupal2spip_lal.base.routers.Drupal2SPIPRouter']
|
||||||
|
|
Loading…
Reference in New Issue