Database versioning

前端 未结 7 1771
抹茶落季
抹茶落季 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条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 20:38

    I prefer to have historical data in another table. I would make foobar_history or something similar and make a FK to foobar_id. This will stop you from having to use a subquery all together. This has the added advantage of not polluting your primary data table with the tons of historical data you probably don't want to see 99% of the time you're accessing it.

    You will likely want to make a trigger for updating this data though, as it would require you to copy the current data in to _history and then do the update.

提交回复
热议问题