修复复盘交易记录并发迁移 prev_entry_tf 导致加载失败。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -87,6 +87,7 @@ def init_options_review_tables(conn: sqlite3.Connection) -> None:
|
||||
strategy_tag TEXT,
|
||||
direction_view TEXT,
|
||||
entry_logic TEXT,
|
||||
prev_entry_tf TEXT,
|
||||
exit_reason TEXT,
|
||||
followed_plan TEXT,
|
||||
mistake_tags TEXT,
|
||||
@@ -141,5 +142,13 @@ def _ensure_column(conn: sqlite3.Connection, table: str, col: str, typedef: str)
|
||||
names.add(str(r["name"]))
|
||||
except (TypeError, KeyError, IndexError):
|
||||
names.add(str(r[1]))
|
||||
if col not in names:
|
||||
if col in names:
|
||||
return
|
||||
try:
|
||||
conn.execute(f"ALTER TABLE {table} ADD COLUMN {col} {typedef}")
|
||||
except sqlite3.OperationalError as e:
|
||||
# 并发首启时多个请求同时 ADD,后者报 duplicate column — 可忽略
|
||||
msg = str(e).lower()
|
||||
if "duplicate column" in msg or "already exists" in msg:
|
||||
return
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user