Migrations
This page is generated from the project corpus and rewritten on every docs build. Edit the source in corpus/, not here.
Split out of data.md on 2026-10-02, when the per-step transaction note pushed that page past the cap.
History
| Version | Shape |
|---|---|
| 1 | CLI era: posts(date, run_number, payload, output_dir), articles(scraped_at) |
| 2 | Web app: posts.payload + status draft|rendered + output_dir, settings |
| 3 | Authored posts: posts.markup, keywords, post_keywords, renders, users, uploads, sources in the DB |
| 4 | The theme family: warm-industrial → warm-industrial-1 in posts.theme, the column default, and the defaultTheme setting |
| 5 | Identity moves to Ward: the users table is dropped. Nothing referenced it, so nothing else changes. |
| 6 | The Reader (2026-10-09): feed_items; sources gains category, etag, last_modified, last_fetched_at, last_error; articles gains note. Every row survives. |
The library's auth_* tables are not versioned here: it keeps its own
auth_migrations table and applies it on boot (2026-10-13), leaving
user_version alone.
A fresh database is created at version 6 directly; an existing one walks every
step in one boot. migrate() (core/src/storage/db.ts) keys on
PRAGMA user_version and uses IF NOT EXISTS throughout, so re-running is a
no-op. Each step is one transaction together with its user_version bump
(runMigrationStep, since 2026-10-02): a crash mid-step rolls back to the previous
version's intact schema, and the step runs again on the next boot. The v3 → v4
table rebuild turns foreign keys off around its transaction, because SQLite
ignores that pragma inside one.
v2 → v3 destroys rows on purpose. A v2 post held a composed slide payload
with no markup to derive it from, and v2 articles were transient scrape output.
Both tables are dropped and recreated, so every v2 post row and every v2
article row is deleted. settings survives untouched. A v1 database walks
v1 → v2 → v3 in one boot and loses its posts the same way.
v5 → v6 guards each ADD COLUMN. A v1 or v2 database reaches it through
v2 → v3, which builds its tables from the current schema and so already has
the new columns; adding one twice would throw and roll the step back on every
boot. The new columns also come last in the current schema, so a migrated
table and a fresh one have the same column order. The step's test builds a v5
database from the schema as it shipped, with a source and a saved article. The
one real database on hand (2026-10-09, a local v4 with six sources, two posts
and no saved articles) walked v4 → v6 on a copy with every row intact.