feat: derive POSTGRES_DB and Redis prefix from DEPLOY_STAGE for pipeline isolation
This commit is contained in:
@@ -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"),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user