Drafts of every record, previewed on the real page
Migration 077 keeps one draft per record of any entity. Saving a draft checks it by applying it in a transaction that is rolled back; Preview opens the record's page in a tab that sends X-Draft-Preview, and the server answers those reads from a second connection holding the applied draft, then rolls back, so nobody else sees it. Publish is the ordinary save, which drops the draft. tx() now nests as a savepoint. Also commits TODO.md: the answered questions, and parts 1 to 3 moved to Done. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e4c7e165d1
commit
a6c66d4607
13 changed files with 576 additions and 65 deletions
25
server/src/migrations/077_drafts.sql
Normal file
25
server/src/migrations/077_drafts.sql
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- ═══════════════════════════════════════════════════════════════
|
||||
-- 077 DRAFTS
|
||||
--
|
||||
-- A record's changes saved without going live: one draft per
|
||||
-- record, of any entity the admin edits (events, people, pages,
|
||||
-- Navigation...). payload is the editor's whole form, as a save
|
||||
-- would send it; publishing is that save, which then drops the
|
||||
-- draft. Anyone who can edit the record can save, preview, publish
|
||||
-- or discard it (drafts.js).
|
||||
--
|
||||
-- base_updated_at is the record's updated_at when the draft was
|
||||
-- started, so the editor can say the live record changed since.
|
||||
-- ═══════════════════════════════════════════════════════════════
|
||||
|
||||
CREATE TABLE drafts (
|
||||
entity TEXT NOT NULL, -- the descriptor key, eg. 'events'
|
||||
record_id TEXT NOT NULL,
|
||||
payload TEXT NOT NULL CHECK (json_valid(payload)),
|
||||
base_updated_at TEXT,
|
||||
created_by INTEGER REFERENCES admin_users (id) ON DELETE SET NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
updated_by INTEGER REFERENCES admin_users (id) ON DELETE SET NULL,
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
PRIMARY KEY (entity, record_id)
|
||||
) STRICT;
|
||||
Loading…
Add table
Add a link
Reference in a new issue