← ClaudeAtlas

add-store-querylisted

Use when adding or modifying a SQL query against the SQLite store — symptoms include "add a method to *Store", "new column on nodes", "expose X via the store", "add an index", "support a new lookup", "write a migration", or any change to `pkg/store/queries.go`, `pkg/store/*.go` methods, or `migrations/`. Covers both the read/write method workflow and the schema-migration workflow with FTS5 trigger sync.
radimsem/remindb · ★ 114 · AI & Automation · score 83
Install: claude install-skill radimsem/remindb
# Add a query (and optionally a migration) to the store `pkg/store/` is the SQLite layer. Queries are SQL string constants in `queries.go`; methods on `*Store` execute them through `s.Tx(...)` for writes or `s.db.QueryContext(...)` for reads. Schema lives in `migrations/000N_*.sql`, embedded via `embed.FS` and applied at startup. There are two workflows here. Pick the right one before you start. ``` Need new SQL only? ──> Workflow A (query) Need a new column / table / index? ──> Workflow A + Workflow B (migration) ``` ## Workflow A — add a query and method Three files. Same pattern every time. | File | What changes | |---|---| | `pkg/store/queries.go` | Add a `q<Verb><Noun> = ...` const | | `pkg/store/<domain>.go` | Add the method on `*Store` (`temperature.go`, `node.go`, `search.go`, `snapshot.go` — pick the matching domain) | | `pkg/store/store_test.go` | Add a test that opens `testutil.OpenTestDB(t)` and exercises the method | ### Query const Constants are grouped at the bottom of `queries.go` next to related queries. Name them `q<Verb><Noun>` — e.g., `qSelectColdNodes`, `qBoostTemperature`, `qIncrementAccess`. No package prefix; the file is the namespace. ```go const qListSourceFiles = `SELECT DISTINCT source_file FROM nodes ORDER BY source_file` ``` For batch queries with a variable IN list, follow the `qBoostTemperatureBatchPrefix` pattern: define the prefix as a const, append placeholders + `)` in the calling method. ### Method shape Two flavors based on