From 283f75a5e21fe0fec4725a122c6be4c5f53e2b8c Mon Sep 17 00:00:00 2001 From: Ami Date: Tue, 21 Apr 2026 17:43:17 +0700 Subject: [PATCH] fix(alembic): URL-decode DATABASE_URL before passing to ConfigParser --- apps/api/alembic/env.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/api/alembic/env.py b/apps/api/alembic/env.py index 37e8332..cf5ad7d 100644 --- a/apps/api/alembic/env.py +++ b/apps/api/alembic/env.py @@ -1,5 +1,6 @@ import os from logging.config import fileConfig +from urllib.parse import unquote from sqlalchemy import engine_from_config, pool @@ -14,6 +15,9 @@ database_url = os.environ.get("DATABASE_URL") if database_url: # Alembic needs the synchronous driver database_url = database_url.replace("postgresql+asyncpg://", "postgresql://") + # Decode URL-encoded characters (e.g. %40 -> @) so ConfigParser + # interpolation doesn't choke on them + database_url = unquote(database_url) config.set_main_option("sqlalchemy.url", database_url) # Set up Python logging from the config file