From 0ffba2167c4465ff43d63ddd469bbba06c6b87d7 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 25 Apr 2026 21:43:27 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20normalize=20DATABASE=5FURL=20for=20Railw?= =?UTF-8?q?ay=20Postgres=20(postgres://=20=E2=86=92=20postgresql+asyncpg:/?= =?UTF-8?q?/)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Railway Postgres gives postgres:// but SQLAlchemy asyncpg needs postgresql+asyncpg://. This was the root cause of all Railway crashes. https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs --- salesflow-saas/backend/app/database.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/salesflow-saas/backend/app/database.py b/salesflow-saas/backend/app/database.py index 26029b5f..d962bfdb 100644 --- a/salesflow-saas/backend/app/database.py +++ b/salesflow-saas/backend/app/database.py @@ -16,7 +16,14 @@ def _get_db_url() -> str: break except FileNotFoundError: continue - return url or "sqlite+aiosqlite:///./dealix.db" + if not url: + return "sqlite+aiosqlite:///./dealix.db" + # Railway Postgres gives postgres:// but SQLAlchemy needs postgresql+asyncpg:// + if url.startswith("postgres://"): + url = url.replace("postgres://", "postgresql+asyncpg://", 1) + elif url.startswith("postgresql://"): + url = url.replace("postgresql://", "postgresql+asyncpg://", 1) + return url _DB_URL = _get_db_url()