(db: DatabaseAdapter)
| 452 | * Returns table names + full column info via PRAGMA table_info. |
| 453 | */ |
| 454 | export function getSchemaDetailed(db: DatabaseAdapter): TableSchema[] { |
| 455 | const tables = db |
| 456 | .prepare( |
| 457 | `SELECT name FROM sqlite_master |
| 458 | WHERE type='table' AND name NOT LIKE 'sqlite_%' |
| 459 | ORDER BY name` |
| 460 | ) |
| 461 | .all() as Array<{ name: string }> |
| 462 | |
| 463 | return tables.map((table) => { |
| 464 | const columns = db.prepare(`PRAGMA table_info('${table.name}')`).all() as Array<{ |
| 465 | cid: number |
| 466 | name: string |
| 467 | type: string |
| 468 | notnull: number |
| 469 | dflt_value: unknown |
| 470 | pk: number |
| 471 | }> |
| 472 | |
| 473 | return { |
| 474 | name: table.name, |
| 475 | columns: columns.map((col) => ({ |
| 476 | name: col.name, |
| 477 | type: col.type, |
| 478 | notnull: col.notnull === 1, |
| 479 | pk: col.pk === 1, |
| 480 | })), |
| 481 | } |
| 482 | }) |
| 483 | } |
| 484 | |
| 485 | // ==================== Context & Conversation Queries ==================== |
| 486 |
no test coverage detected