Draft vs published
The three data stores — draft tables, the published snapshot, and version history — and what reads which.
Sajt keeps three distinct stores. Knowing which surface reads which prevents the most common mistake: assuming an edit is already live, or that "version history" is the same as the public site. The developer reference is Data model.
1. Draft (what you edit)
The draft world is the normalized, mutable tables: websites, pages,
sections, services, assets, fonts, and so on. Every edit — inline text,
section add/hide/reorder, theme change, image upload, AI-chat edit — writes here.
Reads the draft:
- the editor canvas,
- the owner preview (
/preview/<websiteId>), - shareable preview links (
/p/<token>).
These three always show the latest draft. That is why preview shows unpublished work — and why it is the right place to send a user to check changes before they go live.
2. Published (what visitors see)
Publishing writes one immutable, denormalized snapshot row (siteVersions).
The site's publishedVersionId pointer flips to it atomically. The snapshot is a
self-contained delivery copy: pages, visible sections, resolved image URLs, frozen
globals and SEO.
Reads the snapshot only:
- the public site
/site/<slug>(and its subdomain / custom-domain forms).
The public site never reads draft tables. If it appears to, that is a bug. A snapshot is never mutated in place — republishing inserts a new snapshot and moves the pointer; older snapshots stay immutable.
3. Version history (a separate restore store)
Restore points are a third store — the user-facing version-history timeline. Each is a normalized copy of the draft taken automatically (before an AI edit batch, on publish, and on a periodic auto-backup) or manually.
Key facts:
- A restore writes into the draft world — it never changes the public site. After restoring, the user still has to publish to make it live.
- Restore points are a different shape from the public snapshot: they are the normalized copy restore reads back, not the denormalized delivery blob.
- Restoring is itself undoable (a "pre-restore" copy is taken first).
Putting it together
| Surface | Reads | Live to the public? |
|---|---|---|
| Editor canvas | Draft | No |
/preview/<websiteId> | Draft | No |
/p/<token> share link | Draft | No (link-gated, noindex) |
Public /site/<slug> | Published snapshot only | Yes |
| Restore / version history | Writes draft | No — must publish after |
So: an edit is in the draft the instant it autosaves, visible in preview immediately, but not public until the user publishes. "Undo," "restore," and "preview" all operate on the draft; only Publish touches the live snapshot. See the publishing model.