feat(ai_news): add news_sentiment.source column with migration
This commit is contained in:
@@ -124,6 +124,7 @@ CREATE TABLE IF NOT EXISTS news_sentiment (
|
|||||||
tokens_input INTEGER NOT NULL DEFAULT 0,
|
tokens_input INTEGER NOT NULL DEFAULT 0,
|
||||||
tokens_output INTEGER NOT NULL DEFAULT 0,
|
tokens_output INTEGER NOT NULL DEFAULT 0,
|
||||||
model TEXT NOT NULL DEFAULT 'claude-haiku-4-5-20251001',
|
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')),
|
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime')),
|
||||||
PRIMARY KEY (ticker, date)
|
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",
|
"UPDATE screener_settings SET weights_json=?, node_params_json=? WHERE id=1",
|
||||||
(json.dumps(w), json.dumps(p)),
|
(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()
|
existing = conn.execute("SELECT id FROM screener_settings WHERE id=1").fetchone()
|
||||||
if existing is None:
|
if existing is None:
|
||||||
now = datetime.now(timezone.utc).isoformat()
|
now = datetime.now(timezone.utc).isoformat()
|
||||||
|
|||||||
Reference in New Issue
Block a user