Drop schema migrations
The index is a cache. Everything in it is re-derived from the statements and rules.toml, and has been since the last hand-set tags went, so keeping machinery to nurse an old index through a schema change was paying for a guarantee nothing needs. The ALTER TABLE lists, the dropped-column list and the pragma_table_info reader are gone; Open applies the schema and returns. What replaces it is a line in the release note: delete index.db and import again. The two directions are not symmetric, which is worth knowing before assuming something is broken. Removing a column leaves an older index working, carrying the dead column and its data unread, because every statement here names its columns -- that is why the drop half was never really load-bearing. Adding a column the code reads breaks every command against an older index with `no such column` until the file is deleted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,23 @@ reproducible and retag stops being safe. Covered by `TestRetagRewritesEveryTag`.
|
||||
`index.db` at the root of the data directory and re-importing must reproduce
|
||||
everything, with nothing lost.
|
||||
|
||||
**The index is a cache, so there are no migrations.** `store.Open` applies
|
||||
`schema` and nothing else — no `ALTER TABLE`, no version column, no repair of
|
||||
an index an older build wrote. Changing the schema costs one line in the
|
||||
release note: delete `index.db` and import again. The two directions are not
|
||||
symmetric, which is worth knowing before you assume something is broken:
|
||||
|
||||
- *Removing* a column leaves an older index still working, carrying the dead
|
||||
column and its data unread.
|
||||
- *Adding* one the code reads breaks every command against an older index with
|
||||
`query transactions: SQL logic error: no such column: …` until it is deleted.
|
||||
|
||||
That asymmetry holds only because every statement names its columns —
|
||||
**no `SELECT *`, and nothing may depend on column order.** Keep it that way.
|
||||
Do not reintroduce migration machinery either; if re-parsing ever becomes too
|
||||
expensive to ask for, that is a decision to revisit deliberately rather than a
|
||||
helper to slip back in.
|
||||
|
||||
**Dedupe is by fingerprint**: `sha256(date | amount | normalised description |
|
||||
ordinal)`, where the ordinal distinguishes identical lines *within one
|
||||
statement*. Two identical purchases on one day both survive; the same line in an
|
||||
@@ -123,6 +140,11 @@ money --root /tmp/.../demo import # must report 0 new
|
||||
money --root /tmp/.../demo ls --wide
|
||||
```
|
||||
|
||||
If you changed the schema, delete that root's `index.db` first. Nothing
|
||||
migrates it, so a demo root left over from an earlier build either carries dead
|
||||
columns or fails with `no such column`, depending on which way the schema
|
||||
moved.
|
||||
|
||||
### Driving the TUI in tests
|
||||
|
||||
Prefer feeding `tea.Msg` values to `Model.Update` directly — that is how every
|
||||
|
||||
Reference in New Issue
Block a user