From b3287d5546012070e3168e79bf63420d012a8909 Mon Sep 17 00:00:00 2001 From: sandyr Date: Wed, 3 Jan 2024 15:17:40 +0000 Subject: [PATCH 1/2] restore ability to recreate test DB fixtures; recreate them --- config/local-lite.yml | 1 + emgena/models.py | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/config/local-lite.yml b/config/local-lite.yml index dd2fa4381..0162f7cbd 100644 --- a/config/local-lite.yml +++ b/config/local-lite.yml @@ -9,6 +9,7 @@ emg: era: ENGINE: 'django.db.backends.sqlite3' NAME: '/opt/ci/testdbs/ena-testdb.sqlite' + ERA_TABLESPACE_PREFIX: '' admin: True downloads_bypass_nginx: True diff --git a/emgena/models.py b/emgena/models.py index c3aaba848..ad7e9b0aa 100644 --- a/emgena/models.py +++ b/emgena/models.py @@ -27,7 +27,9 @@ from __future__ import unicode_literals from datetime import date -from django.db import models, NotSupportedError + +from django.conf import settings +from django.db import models class Status(models.IntegerChoices): @@ -197,8 +199,9 @@ class Meta(StudyAbstract.Meta): # ERA needs to be appended as the default connection tries to use # the PUBLIC SYNONYM (according to ENA) and it's not working ATM # we were advised to prefix the views and this is the simplest way. - # The short-term plan is to remove the dependency of ENA databases - db_table = 'ERA\".\"V_MGP_RUN_STUDY' + # The short-term plan is to remove the dependency of ENA databases + _prefix_workaround = settings.DATABASES['era'].get('ERA_TABLESPACE_PREFIX', 'ERA\".\"') + db_table = f'{_prefix_workaround}V_MGP_RUN_STUDY' class AssemblyStudy(StudyAbstract): From ed1604b1ec61f5f6cad7b2fd8e08a463e9bc0c01 Mon Sep 17 00:00:00 2001 From: sandyr Date: Wed, 3 Jan 2024 15:59:02 +0000 Subject: [PATCH 2/2] allow ERA database to be non existent --- emgena/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emgena/models.py b/emgena/models.py index ad7e9b0aa..85beb7a48 100644 --- a/emgena/models.py +++ b/emgena/models.py @@ -200,7 +200,7 @@ class Meta(StudyAbstract.Meta): # the PUBLIC SYNONYM (according to ENA) and it's not working ATM # we were advised to prefix the views and this is the simplest way. # The short-term plan is to remove the dependency of ENA databases - _prefix_workaround = settings.DATABASES['era'].get('ERA_TABLESPACE_PREFIX', 'ERA\".\"') + _prefix_workaround = settings.DATABASES.get('era', {}).get('ERA_TABLESPACE_PREFIX', 'ERA\".\"') db_table = f'{_prefix_workaround}V_MGP_RUN_STUDY'