| 600 | } |
| 601 | |
| 602 | private migrateMergeFields(): void { |
| 603 | const cols = this.db.prepare("PRAGMA table_info(chunks)").all() as Array<{ name: string }>; |
| 604 | if (!cols.some((c) => c.name === "merge_count")) { |
| 605 | this.db.exec("ALTER TABLE chunks ADD COLUMN merge_count INTEGER NOT NULL DEFAULT 0"); |
| 606 | this.db.exec("ALTER TABLE chunks ADD COLUMN last_hit_at INTEGER"); |
| 607 | this.db.exec("ALTER TABLE chunks ADD COLUMN merge_history TEXT NOT NULL DEFAULT '[]'"); |
| 608 | this.log.info("Migrated: added merge_count/last_hit_at/merge_history columns to chunks"); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | private migrateApiLogs(): void { |
| 613 | this.db.exec(` |