From dc4958e64588e17c90170ef19a5f38e6551bffe0 Mon Sep 17 00:00:00 2001 From: Untone Date: Wed, 20 Aug 2025 21:31:47 +0300 Subject: [PATCH] schema-fix --- storage/schema.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/schema.py b/storage/schema.py index c4fde552..be2785d0 100644 --- a/storage/schema.py +++ b/storage/schema.py @@ -68,7 +68,10 @@ def create_all_tables() -> None: collection.ShoutCollection, # Зависит от Collection и Shout ] - with local_session() as session: + from storage.db import engine + + # Используем одно соединение для всех таблиц, чтобы избежать проблем с транзакциями + with engine.connect() as connection: for model in models_in_order: try: # Ensure model is a type[DeclarativeBase] @@ -76,7 +79,7 @@ def create_all_tables() -> None: logger.warning(f"Skipping {model} - not a DeclarativeBase model") continue - create_table_if_not_exists(session.get_bind(), model) # type: ignore[arg-type] + create_table_if_not_exists(connection, model) # type: ignore[arg-type] # logger.info(f"Created or verified table: {model.__tablename__}") except Exception as e: table_name = getattr(model, "__tablename__", str(model))