Spaces:
Runtime error
Runtime error
Download backend/alembic/env.py from firebird-technologies/NoteStack-Test: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/firebird-technologies/NoteStack-Test/resolve/main/backend/alembic/env.py
- Command line
-
hf download hf://spaces/firebird-technologies/NoteStack-Test/backend/alembic/env.py
-
curl -L -o env.py https://huggingface.co/spaces/firebird-technologies/NoteStack-Test/resolve/main/backend/alembic/env.py
1.31 kB
| from logging.config import fileConfig | |
| from alembic import context | |
| from sqlalchemy import engine_from_config, pool | |
| import app.models # noqa: F401 (register tables) | |
| from app.config import settings | |
| from app.db import Base | |
| config = context.config | |
| config.set_main_option("sqlalchemy.url", settings.database_url) | |
| if config.config_file_name: | |
| fileConfig(config.config_file_name) | |
| target_metadata = Base.metadata | |
| def run_migrations_offline() -> None: | |
| context.configure(url=settings.database_url, target_metadata=target_metadata, literal_binds=True) | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| def run_migrations_online() -> None: | |
| connectable = engine_from_config(config.get_section(config.config_ini_section), prefix="sqlalchemy.", | |
| poolclass=pool.NullPool) | |
| with connectable.connect() as connection: | |
| # Batch mode rebuilds tables for ALTERs that SQLite cannot do in place (local dev only). | |
| context.configure(connection=connection, target_metadata=target_metadata, | |
| render_as_batch=connection.dialect.name == "sqlite") | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| if context.is_offline_mode(): | |
| run_migrations_offline() | |
| else: | |
| run_migrations_online() | |