| 225 | } |
| 226 | |
| 227 | private migrateOwnerFields(): void { |
| 228 | const chunkCols = this.db.prepare("PRAGMA table_info(chunks)").all() as Array<{ name: string }>; |
| 229 | if (!chunkCols.some((c) => c.name === "owner")) { |
| 230 | this.db.exec("ALTER TABLE chunks ADD COLUMN owner TEXT NOT NULL DEFAULT 'agent:main'"); |
| 231 | this.db.exec("CREATE INDEX IF NOT EXISTS idx_chunks_owner ON chunks(owner)"); |
| 232 | this.log.info("Migrated: added owner column to chunks"); |
| 233 | } |
| 234 | const taskCols = this.db.prepare("PRAGMA table_info(tasks)").all() as Array<{ name: string }>; |
| 235 | if (!taskCols.some((c) => c.name === "owner")) { |
| 236 | this.db.exec("ALTER TABLE tasks ADD COLUMN owner TEXT NOT NULL DEFAULT 'agent:main'"); |
| 237 | this.db.exec("CREATE INDEX IF NOT EXISTS idx_tasks_owner ON tasks(owner)"); |
| 238 | this.log.info("Migrated: added owner column to tasks"); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | private migrateSkillVisibility(): void { |
| 243 | const cols = this.db.prepare("PRAGMA table_info(skills)").all() as Array<{ name: string }>; |