Проект разделен на два репозитория

This commit is contained in:
mi
2026-08-14 15:42:45 +03:00
parent e06a77ee1d
commit bbef7a30c9
521 changed files with 2597 additions and 2302 deletions
@@ -0,0 +1,49 @@
import asyncio
import os
from logging.config import fileConfig
from sqlalchemy import pool
from alembic import context
from app.db import Base
from app.postgres import create_postgres_engine
config = context.config
if config.config_file_name:
fileConfig(config.config_file_name)
database_url = os.environ["DATABASE_URL"]
config.set_main_option("sqlalchemy.url", database_url.replace("%", "%%"))
target_metadata = Base.metadata
def do_run_migrations(connection) -> None:
context.configure(
connection=connection,
target_metadata=target_metadata,
include_schemas=True,
version_table_schema="han_app",
compare_type=True,
)
with context.begin_transaction():
context.run_migrations()
async def run_async_migrations() -> None:
connectable = create_postgres_engine(database_url, poolclass=pool.NullPool)
async with connectable.connect() as connection:
await connection.run_sync(do_run_migrations)
await connectable.dispose()
if context.is_offline_mode():
context.configure(
url=config.get_main_option("sqlalchemy.url"),
target_metadata=target_metadata,
literal_binds=True,
include_schemas=True,
version_table_schema="han_app",
)
with context.begin_transaction():
context.run_migrations()
else:
asyncio.run(run_async_migrations())