feat(spip): connecte la db spip

This commit is contained in:
François Poulain 2020-08-01 14:28:53 +02:00
parent a69c9d2549
commit 0e08c4446e
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,8 @@ class Drupal2SPIPRouter:
def db_for_read(self, model, **hints):
if model._meta.app_label == 'drupal':
return 'drupal'
if model._meta.app_label == 'spip':
return 'spip'
return None
def db_for_write(self, model, **hints):
@ -12,7 +14,7 @@ class Drupal2SPIPRouter:
We disallow cross db relations.
"""
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 None
@ -20,6 +22,6 @@ class Drupal2SPIPRouter:
"""
We disallow migrations for those db.
"""
if db == 'drupal':
if db in ['drupal', 'spip']:
return False
return None

View File

@ -60,6 +60,10 @@ DATABASES = {
'DRUPAL_DATABASE_URL',
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']