From 6bde9a9172c86b38d182a8adbe029b8dba69ea86 Mon Sep 17 00:00:00 2001 From: kjh2064 Date: Mon, 6 Jul 2026 18:02:20 +0900 Subject: [PATCH] =?UTF-8?q?refactor(database):=20DbMigrator.cs=EC=97=90=20?= =?UTF-8?q?KIS=20=EC=88=98=EC=A7=91=20=ED=85=8C=EC=9D=B4=EB=B8=94=20?= =?UTF-8?q?=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=B4=88=EA=B8=B0=ED=99=94=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - kis_collection_runs, kis_collection_snapshots, kis_collection_errors 테이블 정의를 DbMigrator.cs의 Migrate()에 추가. - 이를 통해 수집기가 시작되거나 API를 호출하기 전에 스키마가 데이터베이스 초기화 시점에 안전하게 준비되도록 함. --- .../Data/DbMigrator.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/dotnet/QuantEngine.Infrastructure/Data/DbMigrator.cs b/src/dotnet/QuantEngine.Infrastructure/Data/DbMigrator.cs index 81ee533..eddc1dd 100644 --- a/src/dotnet/QuantEngine.Infrastructure/Data/DbMigrator.cs +++ b/src/dotnet/QuantEngine.Infrastructure/Data/DbMigrator.cs @@ -105,6 +105,44 @@ namespace QuantEngine.Infrastructure.Data CREATE INDEX IF NOT EXISTS idx_collection_source_errors_run ON collection_source_errors(run_id, source_name); "); + // 3b. KIS 데이터 수집 테이블 추가 (kis_collection_runs, kis_collection_snapshots, kis_collection_errors) + conn.Execute(@" + CREATE TABLE IF NOT EXISTS kis_collection_runs ( + run_id TEXT PRIMARY KEY, + status TEXT NOT NULL, + started_at TEXT NOT NULL, + finished_at TEXT, + total_snapshots INTEGER, + total_errors INTEGER, + updated_at TEXT NOT NULL + ); + CREATE INDEX IF NOT EXISTS idx_kis_runs_started_at ON kis_collection_runs(started_at DESC); + + CREATE TABLE IF NOT EXISTS kis_collection_snapshots ( + run_id TEXT NOT NULL, + dataset_name TEXT, + ticker TEXT NOT NULL, + source_name TEXT NOT NULL, + payload_json TEXT NOT NULL, + captured_at TEXT NOT NULL, + created_at TEXT NOT NULL, + PRIMARY KEY (run_id, ticker, source_name) + ); + CREATE INDEX IF NOT EXISTS idx_kis_snapshots_ticker ON kis_collection_snapshots(ticker); + CREATE INDEX IF NOT EXISTS idx_kis_snapshots_captured_at ON kis_collection_snapshots(captured_at DESC); + + CREATE TABLE IF NOT EXISTS kis_collection_errors ( + id SERIAL PRIMARY KEY, + run_id TEXT NOT NULL, + source_name TEXT NOT NULL, + error_kind TEXT NOT NULL, + error_message TEXT, + ticker TEXT, + created_at TEXT NOT NULL + ); + CREATE INDEX IF NOT EXISTS idx_kis_errors_run_id ON kis_collection_errors(run_id); + "); + // 4. settings conn.Execute(@" CREATE TABLE IF NOT EXISTS settings (