Commit c9fbde98 authored by Aryan Noshirvnai's avatar Aryan Noshirvnai

Fix DATABASE_URL silently ignoring .env outside the FastAPI app

database.py read os.getenv("DATABASE_URL") at import time, relying on
config.py's load_dotenv() having already run first. Anything that imports
database.py directly - alembic/env.py, the standalone Telegram bot's
init_db() - never loads .env at all and silently falls back to the
sqlite:///./stax.db default, no matter what .env actually says. Found
while deploying to a fresh prod server: alembic kept migrating a stale
leftover database instead of the one set up for it.
Co-Authored-By: 's avatarClaude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i3NAUkLkHNbsPg5vKfzF9
parent 7f2abd19
Pipeline #1251 failed with stage