diff --git a/stock-lab/app/screener/schema.py b/stock-lab/app/screener/schema.py index 7a48f3d..e81d75b 100644 --- a/stock-lab/app/screener/schema.py +++ b/stock-lab/app/screener/schema.py @@ -124,6 +124,7 @@ CREATE TABLE IF NOT EXISTS news_sentiment ( tokens_input INTEGER NOT NULL DEFAULT 0, tokens_output INTEGER NOT NULL DEFAULT 0, model TEXT NOT NULL DEFAULT 'claude-haiku-4-5-20251001', + source TEXT NOT NULL DEFAULT 'articles', created_at TEXT NOT NULL DEFAULT (datetime('now','localtime')), PRIMARY KEY (ticker, date) ); @@ -158,6 +159,15 @@ def ensure_screener_schema(conn: sqlite3.Connection) -> None: "UPDATE screener_settings SET weights_json=?, node_params_json=? WHERE id=1", (json.dumps(w), json.dumps(p)), ) + # news_sentiment.source 컬럼 1회 추가 (기존 운영 환경) + cols = {r[1] for r in conn.execute( + "PRAGMA table_info(news_sentiment)" + ).fetchall()} + if "source" not in cols: + conn.execute( + "ALTER TABLE news_sentiment " + "ADD COLUMN source TEXT NOT NULL DEFAULT 'articles'" + ) existing = conn.execute("SELECT id FROM screener_settings WHERE id=1").fetchone() if existing is None: now = datetime.now(timezone.utc).isoformat()