feat: migrate var/tag store from JSONL to better-sqlite3 #68

Merged
xiaomo merged 2 commits from feat/60-sqlite-var-tag into main 2026-06-03 08:40:46 +00:00

2 Commits

Author SHA1 Message Date
xiaoju 72ba313d12 fix: address review — transactions, LIKE escape, post-filter pagination
Critical fixes:
1. LIKE ESCAPE '\' clause added for namePrefix queries
2. list() limit/offset now applied AFTER tag/label post-filter
3. tag()/untag() wrapped in db.transaction()

Warning fixes:
4. set()/update() wrapped in db.transaction() (txnSetVar)
5. listByTag sort/limit/offset pushed to SQL
6. close() idempotent (double-close guard)
7. JSONL → SQLite migration on first open (vars + tags)
8. History truncation simplified (NOT IN subquery)
9. Removed unnecessary pre-fetch in upsert (ON CONFLICT handles it)

Nits:
10. Database.Database type instead of InstanceType
11. row.name instead of row["name"]
12. DESC index on var_history position
13. key+value composite index on tags
2026-06-03 08:38:44 +00:00
xiaoju 1fe6035be5 feat: migrate var/tag store from JSONL to better-sqlite3
- New sqlite-store.ts: VarStore + TagStore backed by SQLite (WAL mode)
- Tables: vars (composite PK name+schema), var_history (with MAX_HISTORY truncation), tags (composite PK target+key)
- Indexed queries for name, created, updated, tag key
- Tags/labels stored as JSON columns with post-filter
- Removed var-store.ts (JSONL append-log implementation)
- Updated tests: JSONL assertions → SQLite db file checks

Closes #60
2026-06-03 08:29:22 +00:00