Spaces:
Running on T4
Running on T4
Download backend/migrations/env.py from modventures/baseball-engine: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/migrations/env.py
- Command line
-
hf download hf://spaces/modventures/baseball-engine/backend/migrations/env.py
-
curl -L -o env.py https://huggingface.co/spaces/modventures/baseball-engine/resolve/main/backend/migrations/env.py
1.07 kB
| """Alembic environment: uses DATABASE_URL from app settings and the app's metadata.""" | |
| import asyncio | |
| from logging.config import fileConfig | |
| from alembic import context | |
| from sqlalchemy.ext.asyncio import create_async_engine | |
| from app.core.config import get_settings | |
| from app.models import Base | |
| if context.config.config_file_name: | |
| fileConfig(context.config.config_file_name) | |
| target_metadata = Base.metadata | |
| def _run(connection) -> None: | |
| context.configure(connection=connection, target_metadata=target_metadata, compare_type=True) | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| async def _run_async() -> None: | |
| engine = create_async_engine(get_settings().database_url) | |
| async with engine.connect() as connection: | |
| await connection.run_sync(_run) | |
| await engine.dispose() | |
| if context.is_offline_mode(): | |
| context.configure(url=get_settings().database_url, target_metadata=target_metadata, literal_binds=True) | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| else: | |
| asyncio.run(_run_async()) | |