Buckets:
| from logging.config import fileConfig | |
| from sqlalchemy import engine_from_config | |
| from sqlalchemy import pool | |
| from alembic import context | |
| from src.core.config.config import settings | |
| from src.models.models import Base | |
| # Load environment variables from .env if needed | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| # this is the Alembic Config object, which provides access to the .ini file | |
| config = context.config | |
| config.set_main_option("sqlalchemy.url", settings.database_url) | |
| # Interpret the config file for Python logging. | |
| fileConfig(config.config_file_name) | |
| # Set the metadata for Alembic to use | |
| target_metadata = Base.metadata | |
| def run_migrations_offline(): | |
| """Run migrations in 'offline' mode.""" | |
| url = config.get_main_option("sqlalchemy.url") | |
| context.configure(url=url, target_metadata=target_metadata) | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| def run_migrations_online(): | |
| """Run migrations in 'online' mode.""" | |
| connectable = engine_from_config( | |
| config.get_section(config.config_ini_section), | |
| prefix="sqlalchemy.", | |
| poolclass=pool.NullPool, | |
| ) | |
| with connectable.connect() as connection: | |
| context.configure(connection=connection, target_metadata=target_metadata) | |
| with context.begin_transaction(): | |
| context.run_migrations() | |
| if context.is_offline_mode(): | |
| run_migrations_offline() | |
| else: | |
| run_migrations_online() | |
Xet Storage Details
- Size:
- 1.43 kB
- Xet hash:
- 0dec894d8528b024f57cff5a6c6391346a9a7f42f6bfd0c6f8cba7165252f898
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.