feat: derive POSTGRES_DB and Redis prefix from DEPLOY_STAGE for pipeline isolation

This commit is contained in:
Celes Renata
2026-04-20 01:33:14 +00:00
parent d64ce82649
commit 8f67d326c9
2 changed files with 11 additions and 2 deletions
+7 -1
View File
@@ -105,6 +105,12 @@ def _bucket(name: str) -> str:
prefix = os.getenv("DEPLOY_STAGE", "")
return f"{prefix}-{name}" if prefix else name
def _stage_db() -> str:
"""Derive database name from DEPLOY_STAGE. Empty stage = 'stonks'."""
stage = os.getenv("DEPLOY_STAGE", "")
return f"stonks_{stage}" if stage else "stonks"
BUCKET_RETENTION_FIELDS: dict[str, str] = {
_bucket("stonks-raw-market"): "raw_market_days",
_bucket("stonks-raw-news"): "raw_news_days",
@@ -229,7 +235,7 @@ def load_config() -> AppConfig:
postgres=PostgresConfig(
host=os.getenv("POSTGRES_HOST", "localhost"),
port=int(os.getenv("POSTGRES_PORT", "5432")),
database=os.getenv("POSTGRES_DB", "stonks"),
database=os.getenv("POSTGRES_DB", "") or _stage_db(),
user=os.getenv("POSTGRES_USER", "stonks"),
password=os.getenv("POSTGRES_PASSWORD", "stonks_dev"),
),