Skip to main content

Module revision

Module revision 

Source
Expand description

Revision — versioned snapshots of cms_page rows.

Captured on every page save in the admin. Each revision stores the full page state as JSON; prune bounds storage.

Structs§

PruneOutcome
Outcome of one prune sweep against a page.
Revision
One row per save of a Page. sequence is a per-page monotonic counter starting at 1.

Enums§

FieldDiff
One field’s diff outcome for the compare view.

Constants§

DEFAULT_KEEP_LATEST
Default keep_latest cap when the caller doesn’t override it.

Functions§

capture
Capture one revision for page: a full-state snapshot under the page’s next sequence.
diff_snapshots
Compare two page revision snapshots field-by-field. Returns one FieldDiff per declared diff field (see DIFF_FIELDS), in declaration order.
ensure_unique_sequence
Give cms_revision its UNIQUE (page_id, sequence) index, so a concurrent save can’t reuse a sequence. Pages that already hold duplicates are renumbered first, in (sequence, id) order, which keeps their history’s order. Idempotent.
page_sequences
(id, page_id, sequence) of every revision of the given pages — light columns only, never the snapshots. The history screen uses it for the “latest” flag and the Compare link, which have to be right for a row at the edge of a page.
prune
Prune old revisions for one page. Returns the count of rows deleted (0 when the page is already under the cap).
prune_all_pages
Run prune against every page in the tenant. Best-effort — per-page failures log + continue so one bad page doesn’t abort the whole sweep. Returns the aggregated (pages_scanned, rows_deleted).