I'm storing code snippets in my database. How can I enable revisions/versions of them?

主宰稳场 提交于 2021-01-28 01:52:58

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/3829348/im-storing-code-snippets-in-my-database-how-can-i-enable-revisions-versions-of

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!