Rails在单个表中进行版本控制,但没有序列化

时间:2021-10-08 11:19:50

I haven't found a gem that does this, but I would like a way to keep my records and their previous versions, all as columns in the same table. I don't want to have duplicates like a Widgets table and a WidgetVersions table like paper_trail, nor do I want a serialized version of my object in a blob in one column. I need everything stored in the database so another IT group can read the previous versions from the database efficiently with no extra processing.

我没有找到一个这样做的宝石,但是我想要一种方法来保存我的记录和它们以前的版本,所有这些都作为同一个表中的列。我不希望像Wilets表和像paper_trail这样的WidgetVersions表有重复项,也不想在一列中的blob中使用我的对象的序列化版本。我需要存储在数据库中的所有内容,以便其他IT组可以高效地从数据库中读取以前的版本,而无需额外处理。

Does anyone know of a gem that works this way, or do I have to roll my own?

有没有人知道这样工作的宝石,还是我必须自己动手?

1 个解决方案

#1


-1  

The simplest way is add two columns to table: revision_id and revision_time.

最简单的方法是向表中添加两列:revision_id和revision_time。

On update you simply create a new record with revision_id + 1 and revision_time = current time

在更新时,您只需使用revision_id + 1和revision_time =当前时间创建新记录

#1


-1  

The simplest way is add two columns to table: revision_id and revision_time.

最简单的方法是向表中添加两列:revision_id和revision_time。

On update you simply create a new record with revision_id + 1 and revision_time = current time

在更新时,您只需使用revision_id + 1和revision_time =当前时间创建新记录