Database versioning

前端 未结 7 1755
抹茶落季
抹茶落季 2021-01-06 20:30

I have made few projects (CMS and EC system) that required to have some data versioned.

Usually I come with that kind of schema

+--------------+
+          


        
7条回答
  •  旧时难觅i
    2021-01-06 20:49

    The cleanest solution in my opinion would be to have a History table for each table that requires versioned. In other words, have a foobar table, and then a foobar_History table, with a trigger on foobar that will write existing data to the History table with a timestamp and user that changed the data. Older data is easily queryably, sorted by timestamp descending, and you know that the data in the main table is always the latest version.

提交回复
热议问题