page.tsx238 lines · main
1import { DocsShell } from '../../components/shell';
2
3export const metadata = { title: 'undo + snapshots' };
4
5export default function UndoPage() {
6 return (
7 <DocsShell>
8 <h1 className="font-mono text-2xl tracking-tight">undo + snapshots</h1>
9 <p className="mt-2 font-mono text-sm text-[var(--color-text-muted)]">
10 briven runs on <strong>DoltGres</strong> — a postgres-compatible database with git-style
11 version control built in. every change to your data can be saved, compared, and undone.
12 it&apos;s the one thing the big no-code databases don&apos;t give you: a real undo button
13 for your whole database.
14 </p>
15
16 <Section title="what it is (plain words)">
17 <p>
18 think of your database like a document you&apos;re editing. most databases only keep the
19 <em> latest</em> version — change something by mistake and the old value is gone. briven
20 keeps a <strong>history of save-points</strong> instead, like the save-points in a video
21 game or the version history in a Google Doc.
22 </p>
23 <ul className="list-disc pl-5">
24 <li>
25 <strong>snapshot</strong> — a save-point of your entire database at a moment in time.
26 </li>
27 <li>
28 <strong>undo / restore</strong> — jump your data back to any earlier save-point.
29 </li>
30 <li>
31 <strong>history</strong> — see what changed, when, and roll back just the part you want.
32 </li>
33 </ul>
34 <p>
35 because nothing is ever truly overwritten, you can experiment fearlessly — there&apos;s
36 always a way back.
37 </p>
38 </Section>
39
40 <Section title="why briven is different">
41 <p>
42 neon, supabase and the rest give developers point-in-time backups, but no non-coder
43 undo. briven&apos;s version history is a product feature, not a buried admin tool —
44 surfaced in plain language so anyone can use it. that&apos;s possible because the engine
45 underneath (DoltGres) treats <em>every commit like git does</em>: cheap, instant, and
46 fully reversible.
47 </p>
48 </Section>
49
50 <Section title="how to use it (no code)">
51 <p>in the dashboard, open your project and use the <strong>Snapshots</strong> panel:</p>
52 <ul className="list-disc pl-5">
53 <li>
54 <strong>take a snapshot</strong> before any big change (e.g. importing a spreadsheet).
55 give it a name you&apos;ll recognise — &ldquo;before price update&rdquo;.
56 </li>
57 <li>
58 <strong>automatic snapshots</strong> can run on a daily / twice-daily schedule with a
59 &ldquo;keep the last N&rdquo; rule, so you always have recent save-points without
60 thinking about it.
61 </li>
62 <li>
63 <strong>restore</strong> picks a snapshot and rolls the whole project back to it. the
64 current state is itself snapshotted first, so a restore is never a dead end.
65 </li>
66 </ul>
67 <p>
68 you never need to type a command. the sections below are for developers who want to know
69 exactly what happens underneath, or who want to drive it from SQL.
70 </p>
71 </Section>
72
73 <Section title="how it works under the hood — DoltGres">
74 <p>
75 <a
76 href="https://www.doltgres.com/docs/introduction/"
77 className="underline underline-offset-2 hover:text-[var(--color-text)]"
78 target="_blank"
79 rel="noreferrer"
80 >
81 DoltGres
82 </a>{' '}
83 is &ldquo;Git and Postgres had a baby&rdquo; — it speaks the postgres wire protocol (so
84 briven&apos;s normal postgres drivers, <code>psql</code>, and your SQL all just work) but
85 stores data the way{' '}
86 <a
87 href="https://www.dolthub.com/docs/introduction/what-is-dolt/"
88 className="underline underline-offset-2 hover:text-[var(--color-text)]"
89 target="_blank"
90 rel="noreferrer"
91 >
92 Dolt
93 </a>{' '}
94 does: as a versioned commit graph. <em>Git versions files; Dolt versions tables.</em>
95 </p>
96 <p>
97 briven turns on commit-on-write for every project database, so each saved transaction
98 becomes its own undoable commit:
99 </p>
100 <Snippet>{`-- briven sets this on every data-plane connection:
101SET dolt_transaction_commit = 1;
102
103-- from then on, a normal write IS a version-controlled commit
104INSERT INTO products (id, name, price) VALUES ('p1', 'Chair', 4900);
105-- the database HEAD now points at a new commit containing that row`}</Snippet>
106 <p>
107 there is <strong>no DoltGres CLI</strong> — all version control is done through SQL
108 functions and system tables. these are the ones briven&apos;s snapshot/undo features call
109 for you:
110 </p>
111 </Section>
112
113 <Section title="for developers — the SQL">
114 <p>
115 <strong>see the history</strong> of a project database (every commit, newest first):
116 </p>
117 <Snippet>{`SELECT commit_hash, committer, message, date
118FROM dolt_log
119ORDER BY date DESC;
120
121-- the exact version the database is on right now:
122SELECT DOLT_HASHOF('HEAD');`}</Snippet>
123
124 <p>
125 <strong>take a named snapshot</strong> (what the dashboard&apos;s &ldquo;take a
126 snapshot&rdquo; button does):
127 </p>
128 <Snippet>{`-- stage everything + commit it as one save-point
129SELECT DOLT_COMMIT('-A', '-m', 'before price update');
130
131-- tag that commit with a friendly snapshot name
132SELECT DOLT_TAG('before-price-update', 'HEAD', '-m', 'before price update');
133
134-- list every snapshot/tag
135SELECT tag_name, message, date FROM dolt_tags;`}</Snippet>
136
137 <p>
138 <strong>see exactly what changed</strong> between two points:
139 </p>
140 <Snippet>{`-- table-by-table summary of changes since the last commit
141SELECT * FROM dolt_diff_summary('HEAD~1', 'HEAD');
142
143-- row-level diff of one table between a snapshot and now
144SELECT * FROM dolt_diff('before-price-update', 'HEAD', 'products');`}</Snippet>
145
146 <p>
147 <strong>undo / restore</strong> — roll the database back to a snapshot:
148 </p>
149 <Snippet>{`-- jump the whole database back to a named snapshot
150SELECT DOLT_RESET('--hard', 'before-price-update');`}</Snippet>
151
152 <p>
153 <strong>experiment on a branch</strong> without touching live data, then merge if you
154 like the result:
155 </p>
156 <Snippet>{`SELECT DOLT_BRANCH('experiment'); -- create a branch
157SELECT DOLT_CHECKOUT('experiment'); -- switch to it
158-- ...make changes safely...
159SELECT DOLT_CHECKOUT('main'); -- back to live
160SELECT DOLT_MERGE('experiment'); -- bring the good changes in`}</Snippet>
161 <p>
162 realtime note: DoltGres has no <code>LISTEN/NOTIFY</code>, so briven&apos;s realtime
163 layer watches <code>DOLT_HASHOF(&apos;HEAD&apos;)</code> per project and pushes an update
164 the moment a commit advances it — see <a className="underline underline-offset-2 hover:text-[var(--color-text)]" href="/realtime">realtime</a>.
165 </p>
166 </Section>
167
168 <Section title="the dolt ecosystem (and what briven uses)">
169 <p>three related projects share the same git-for-data engine. briven uses one of them:</p>
170 <ul className="list-disc pl-5">
171 <li>
172 <strong>
173 <a
174 className="underline underline-offset-2 hover:text-[var(--color-text)]"
175 href="https://www.dolthub.com/docs/introduction/what-is-dolt/"
176 target="_blank"
177 rel="noreferrer"
178 >
179 Dolt
180 </a>
181 </strong>{' '}
182 — the original: a SQL database you can fork, clone, branch, merge, push and pull like a
183 git repo. mysql-dialect. this is the <em>concept</em> briven&apos;s undo is built on.
184 </li>
185 <li>
186 <strong>
187 <a
188 className="underline underline-offset-2 hover:text-[var(--color-text)]"
189 href="https://www.doltgres.com/docs/introduction/"
190 target="_blank"
191 rel="noreferrer"
192 >
193 DoltGres
194 </a>
195 </strong>{' '}
196 — the postgres-dialect version of Dolt. <strong>this is what briven runs</strong> for
197 every customer&apos;s data, so the whole platform stays on the postgres protocol.
198 </li>
199 <li>
200 <strong>
201 <a
202 className="underline underline-offset-2 hover:text-[var(--color-text)]"
203 href="https://www.doltlab.com/docs/introduction/what-is-doltlab/"
204 target="_blank"
205 rel="noreferrer"
206 >
207 DoltLab
208 </a>
209 </strong>{' '}
210 — a self-hosted, GitLab-style collaboration server for Dolt databases (a remote you
211 push to, with pull-request review). it is <em>not</em> a database engine, and{' '}
212 <strong>briven does not use it</strong> — briven embeds the DoltGres engine directly
213 and provides its own dashboard. listed here only so the ecosystem is clear.
214 </li>
215 </ul>
216 </Section>
217 </DocsShell>
218 );
219}
220
221function Section({ title, children }: { title: string; children: React.ReactNode }) {
222 return (
223 <section className="mt-10">
224 <h2 className="font-mono text-lg">{title}</h2>
225 <div className="mt-2 space-y-3 font-mono text-sm text-[var(--color-text-muted)]">
226 {children}
227 </div>
228 </section>
229 );
230}
231
232function Snippet({ children }: { children: string }) {
233 return (
234 <pre className="overflow-x-auto rounded-md border border-[var(--color-border-subtle)] bg-[var(--color-surface)] p-4 font-mono text-xs">
235 <code>{children}</code>
236 </pre>
237 );
238}