alembic env.py supports env var DEXORDER_DB_URL

This commit is contained in:
tim
2024-08-31 19:31:07 -04:00
parent 81c9986d73
commit 16801b56ce

View File

@@ -20,7 +20,13 @@ from sys import path
path.append('src')
import dexorder.database.model
target_metadata = dexorder.database.model.Base.metadata
if not config.get_main_option('sqlalchemy.url'):
import os
# Retrieve the database URL from the environment variable. We do not do a full load of
db_url_env = os.getenv('DEXORDER_DB_URL')
if db_url_env:
config.set_main_option('sqlalchemy.url', db_url_env)
elif not config.get_main_option('sqlalchemy.url'):
config.set_main_option('sqlalchemy.url', dexorder.config.db_url)
# other values from the config, defined by the needs of env.py,