diff --git a/platypush/config/__init__.py b/platypush/config/__init__.py index d2de1fdef..28c6beaaa 100644 --- a/platypush/config/__init__.py +++ b/platypush/config/__init__.py @@ -530,5 +530,12 @@ class Config: # pylint: disable=protected-access cls._get_instance()._config[key] = value + @classmethod + def get_file(cls) -> str: + """ + :return: The main configuration file path. + """ + return cls._get_instance().config_file + # vim:sw=4:ts=4:et: diff --git a/platypush/entities/_base.py b/platypush/entities/_base.py index c3089dde5..2a739124a 100644 --- a/platypush/entities/_base.py +++ b/platypush/entities/_base.py @@ -29,6 +29,7 @@ from sqlalchemy.orm import ColumnProperty, backref, relationship from sqlalchemy.orm.exc import ObjectDeletedError import platypush +from platypush.config import Config from platypush.common.db import Base from platypush.message import JSONAble, Message @@ -355,6 +356,8 @@ def run_db_migrations(): '-c', alembic_ini, '-x', + f'CFGFILE={Config.get_file()}', + '-x', f'DBNAME={_get_db_engine().url}', 'upgrade', 'head', diff --git a/platypush/migrations/alembic/env.py b/platypush/migrations/alembic/env.py index 406b1f6e2..d4aba7078 100644 --- a/platypush/migrations/alembic/env.py +++ b/platypush/migrations/alembic/env.py @@ -74,6 +74,10 @@ def run_migrations_online() -> None: def set_db_engine(): + app_conf_file = context.get_x_argument(as_dictionary=True).get('CFGFILE') + if app_conf_file: + Config.init(app_conf_file) + engine_url = context.get_x_argument(as_dictionary=True).get('DBNAME') if not engine_url: db_conf = Config.get('db')