我将代码段存储在数据库中.如何启用它们的修订/版本? [英] I'm storing code snippets in my database. How can I enable revisions/versions of them?

查看:38
本文介绍了我将代码段存储在数据库中.如何启用它们的修订/版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个漂亮的原始表架构(在Postgres中):

I have a pretty primitive table schema now ( in Postgres ):

CREATE TABLE "public"."sandbox_demo" (
    "id" int4 DEFAULT nextval('sandbox_demo_id_seq'::regclass) NOT NULL,
    "source" text DEFAULT NULL NOT NULL,
    "created" timestamptz(6) DEFAULT NULL NOT NULL,
    "modified" timestamptz(6) DEFAULT NULL NOT NULL
)

但是,该表仅支持简单条目,没有父子关系或映射表,因此我可以对初始代码段进行修订.

However, this table only supports plain entries and there's no parent child relationship or a mapping table so I could have revisions of the initial code snippet.

最理想的方式是支持每个初始代码段的修订版本?

What would be an ideal way of making it so that revisions per initial code snippet are supported?

推荐答案

添加可为空的 parent_id ,以便您可以跟踪原始代码段?

Add a nullable parent_id so you can keep track of the original snippet?

这篇关于我将代码段存储在数据库中.如何启用它们的修订/版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆