Snapshot the code-bearing fields of routes (verb/path/handler), templates (name/content/test_object), and db libraries (name/library) on every content-changing save, so nothing edited is ever lost. Recorded in a new `versions` table via recordVersion() hooked into the create/update functions in db.js (the single write choke point), deduped against the latest snapshot so no-op saves, error-flag-only route writes, and server-restart WS re-bootstraps don't pile up. The live row stays current; old snapshots are the undo trail. Read-only, no revert UI yet. - migrations/004_add_versions.sql: versions table + indexes - db.js: recordVersion/getVersions/getVersion + create/update hooks - plumbing.js: /versions/:id and per-entity .../versions list endpoints - bliss: `versions <type> <sid> <id>` and `version <id>` reads; `update-settings` (edit route_prefix/head_injection, preserving the untouched field); `use <url>` sticky target persisted to ~/.bliss/target so BLISS_URL needn't be re-exported each call - client.js: target-file precedence (BLISS_URL > ~/.bliss/target > localhost) - SKILL.md: document the above Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
15 lines
787 B
SQL
15 lines
787 B
SQL
-- Append-only version history for the code-bearing entities: route handlers,
|
|
-- template content, and db libraries. Every content-changing save records a
|
|
-- snapshot here (see recordVersion in db.js). The live rows in routes/templates/
|
|
-- dbs remain the current version; this table is the "plumber's" undo trail.
|
|
CREATE TABLE versions (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
entity_type TEXT NOT NULL CHECK(entity_type IN ('route', 'template', 'db')),
|
|
entity_id INTEGER NOT NULL,
|
|
structure_id INTEGER,
|
|
snapshot TEXT NOT NULL, -- JSON of the versioned fields
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE INDEX idx_versions_entity ON versions (entity_type, entity_id, id);
|
|
CREATE INDEX idx_versions_structure ON versions (structure_id, id);
|