From b0055e174faa92e2b1c0470238c7411b7426093b Mon Sep 17 00:00:00 2001 From: Doctor Delpy Date: Thu, 11 Dec 2025 11:17:44 +0300 Subject: [PATCH] fix db error --- app/core/_secrets.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/core/_secrets.py b/app/core/_secrets.py index 282d715..be4ff79 100644 --- a/app/core/_secrets.py +++ b/app/core/_secrets.py @@ -32,6 +32,22 @@ def _init_seed_via_db() -> bytes: engine = create_engine(DATABASE_URL, pool_pre_ping=True) role = os.getenv("NODE_ROLE", "worker").lower() + # Best-effort: ensure service_config table exists before waiting on it. + # This complements the synchronous init in app.__main__ and protects + # against ordering issues where _secrets is imported before that init runs. + try: + from sqlalchemy.exc import SQLAlchemyError + + with engine.begin() as conn: + inspector = inspect(conn) + if not inspector.has_table('service_config'): + ServiceConfigValue.__table__.create(bind=conn, checkfirst=True) + except SQLAlchemyError as exc: + make_log("HotWallet", f"Failed to ensure service_config table: {exc}", level="error") + except Exception: + # Avoid failing hard here; the fallback waiter below may still succeed + pass + def db_ready(conn) -> bool: try: inspector = inspect(conn)