You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- add schema versioning and migrate vault/cache metadata columns
- store n_tokens and truncated on vault rows and cache entries
- assert metadata persistence in unittest coverage
- document the remote parser refactor plan for later implementation
if (version!=DBMEM_SCHEMA_VERSION) returnSQLITE_MISMATCH;
460
+
returnSQLITE_OK;
461
+
}
462
+
361
463
staticintdbmem_database_init (sqlite3*db) {
362
464
constchar*sql="CREATE TABLE IF NOT EXISTS dbmem_settings (key TEXT PRIMARY KEY, value TEXT);";
363
465
intrc=sqlite3_exec(db, sql, NULL, NULL, NULL);
@@ -367,14 +469,17 @@ static int dbmem_database_init (sqlite3 *db) {
367
469
rc=sqlite3_exec(db, sql, NULL, NULL, NULL);
368
470
if (rc!=SQLITE_OK) returnrc;
369
471
370
-
sql="CREATE TABLE IF NOT EXISTS dbmem_vault (hash TEXT NOT NULL, seq INTEGER NOT NULL, embedding BLOB NOT NULL, offset INTEGER NOT NULL, length INTEGER NOT NULL, PRIMARY KEY (hash, seq));";
472
+
sql="CREATE TABLE IF NOT EXISTS dbmem_vault (hash TEXT NOT NULL, seq INTEGER NOT NULL, embedding BLOB NOT NULL, offset INTEGER NOT NULL, length INTEGER NOT NULL, n_tokens INTEGER NOT NULL DEFAULT 0, truncated INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (hash, seq));";
371
473
rc=sqlite3_exec(db, sql, NULL, NULL, NULL);
372
474
if (rc!=SQLITE_OK) returnrc;
373
475
374
-
sql="CREATE TABLE IF NOT EXISTS dbmem_cache (text_hash TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL, embedding BLOB NOT NULL, dimension INTEGER NOT NULL, PRIMARY KEY (text_hash, provider, model));";
476
+
sql="CREATE TABLE IF NOT EXISTS dbmem_cache (text_hash TEXT NOT NULL, provider TEXT NOT NULL, model TEXT NOT NULL, embedding BLOB NOT NULL, dimension INTEGER NOT NULL, n_tokens INTEGER NOT NULL DEFAULT 0, truncated INTEGER NOT NULL DEFAULT 0, PRIMARY KEY (text_hash, provider, model));";
375
477
rc=sqlite3_exec(db, sql, NULL, NULL, NULL);
376
478
if (rc!=SQLITE_OK) returnrc;
377
479
480
+
rc=dbmem_database_migrate(db);
481
+
if (rc!=SQLITE_OK) returnrc;
482
+
378
483
sql="CREATE VIRTUAL TABLE IF NOT EXISTS dbmem_vault_fts USING fts5 (content, hash UNINDEXED, seq UNINDEXED, context UNINDEXED);";
379
484
rc=sqlite3_exec(db, sql, NULL, NULL, NULL);
380
485
if (rc!=SQLITE_OK) {
@@ -495,7 +600,7 @@ static int dbmem_database_add_entry (dbmem_context *ctx, sqlite3 *db, uint64_t h
0 commit comments