| 626 | } |
| 627 | |
| 628 | private migrateDedupStatus(): void { |
| 629 | const cols = this.db.prepare("PRAGMA table_info(chunks)").all() as Array<{ name: string }>; |
| 630 | if (!cols.some((c) => c.name === "dedup_status")) { |
| 631 | this.db.exec("ALTER TABLE chunks ADD COLUMN dedup_status TEXT NOT NULL DEFAULT 'active'"); |
| 632 | this.db.exec("ALTER TABLE chunks ADD COLUMN dedup_target TEXT DEFAULT NULL"); |
| 633 | this.db.exec("ALTER TABLE chunks ADD COLUMN dedup_reason TEXT DEFAULT NULL"); |
| 634 | this.db.exec("CREATE INDEX IF NOT EXISTS idx_chunks_dedup_status ON chunks(dedup_status)"); |
| 635 | this.log.info("Migrated: added dedup_status/dedup_target/dedup_reason columns to chunks"); |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | recordApiLog(toolName: string, input: unknown, output: string, durationMs: number, success: boolean): void { |
| 640 | const inputStr = typeof input === "string" ? input : JSON.stringify(input ?? {}); |