TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How do you architect a versioning system?

2 点作者 bostonvaulter2超过 1 年前
A semi-common feature that many SaaS products have the ability to store and restore older versions of a &quot;document&quot;, e.g. Google Docs, Notion, Figma. However, most of these products feel like they have a document rather than db-based model that operates on multiple tables. For example Figma has a great article about how their documents are actually files rather than database rows: https:&#x2F;&#x2F;digest.browsertech.com&#x2F;archive&#x2F;browsertech-digest-figma-is-a-file-editor&#x2F;<p>So for a system that is built on top of multiple database tables to load a single page&#x2F;document how would you go about creating and storing a version history for all the related tables? Or would you use a non-db approach somehow?

2 条评论

paulgb超过 1 年前
(oh hey, author of that article here :))<p>This is something I&#x27;ve been thinking a lot about as well. A cool approach I&#x27;ve been experimenting with is using a CRDT for the underlying document data, and taking snapshots of the logical clock that correspond to version numbers. If you don&#x27;t garbage-collect the CRDT, you can then restore the value based on the logical clock.<p>The CRDT itself can be persisted to S3 or similar, as in that article. We’ve been working on this in the open, so you can follow along: <a href="https:&#x2F;&#x2F;y-sweet.dev&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;y-sweet.dev&#x2F;</a>
评论 #37354655 未加载
eschneider超过 1 年前
If you just need to restore older versions of a (non-text) doc and don&#x27;t need to support things like diff and merge, a handy approach is to store all the steps needed to create the doc, same as you would to implement undo&#x2F;redo and allow &quot;tagging&quot; the operation stream to create your versions.<p>There are a lot of ways to optimize this sort of thing in practice so it runs reasonably, but that&#x27;s an exercise for the implementer.