Every bot file was chunked into bot_file_chunks and embedded into bot_file_vectors, and uploads kept their extracted text in media.text_content, which together took most of the database. Bot files are no longer indexed: bots find them by name or path with list_files and read them with read_file, and search_files, ingest_file and the files modal's re-read button are gone. Attachments keep no text; a reply reads a document from the file. Only knowledgebase documents keep text. The schema drops both tables and the ingest columns. At boot, dropStoredFileText removes what older versions stored (file jobs, upload text) and vacuums once much of the database is free. The media:prune-text script it replaces is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
/**
|
|
* The tables the database browser lists, each with its columns in their
|
|
* declared order, in one statement: `pragma_table_list` finds the tables
|
|
* and `pragma_table_info` reads each one's columns, the pragma taking the
|
|
* table name as an argument the way a table-valued function does.
|
|
*
|
|
* Left out: SQLite's own `sqlite_*` tables, and the shadow tables a
|
|
* virtual table keeps its internals in (the `knowledgebase_vectors_*` tables
|
|
* behind the sqlite-vec index), which are storage, not rows anyone
|
|
* browses.
|
|
*/
|
|
export default function buildTableCatalogSql(): string {
|
|
return `SELECT
|
|
l.name AS table_name,
|
|
l.type AS table_type,
|
|
l.wr AS without_rowid,
|
|
p.cid AS column_index,
|
|
p.name AS column_name,
|
|
p.type AS column_type,
|
|
p.pk AS column_pk
|
|
FROM pragma_table_list AS l
|
|
JOIN pragma_table_info(l.name) AS p
|
|
WHERE l.schema = 'main'
|
|
AND l.type IN ('table', 'virtual')
|
|
AND l.name NOT LIKE 'sqlite\\_%' ESCAPE '\\'
|
|
AND NOT EXISTS (
|
|
SELECT 1
|
|
FROM pragma_table_list AS v
|
|
WHERE v.type = 'virtual'
|
|
AND l.name LIKE v.name || '\\_%' ESCAPE '\\'
|
|
)
|
|
ORDER BY l.name ASC, p.cid ASC`;
|
|
}
|