From f51aa3133c17a6bffc4d4114db4430d914d03e98 Mon Sep 17 00:00:00 2001 From: itqop Date: Wed, 31 Dec 2025 02:06:04 +0300 Subject: [PATCH] add auto migrations --- backend/alembic/env.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/backend/alembic/env.py b/backend/alembic/env.py index 7ebf571..e647447 100644 --- a/backend/alembic/env.py +++ b/backend/alembic/env.py @@ -21,8 +21,17 @@ if config.config_file_name is not None: fileConfig(config.config_file_name) # Get database URL from settings -settings = get_settings() -config.set_main_option("sqlalchemy.url", settings.database_url) +import os + +db_url = os.environ.get("DATABASE_URL") +if not db_url: + raise RuntimeError("DATABASE_URL is not set") + +# Alembic sync-only URL +db_url = db_url.replace("sqlite+aiosqlite://", "sqlite:///") +db_url = db_url.replace("postgresql+asyncpg://", "postgresql://") + +config.set_main_option("sqlalchemy.url", db_url) # Add your model's MetaData object here for 'autogenerate' support target_metadata = Base.metadata