We would like to implement Multiversion concurrency control for our Symfony2 webapp.
This means that on any event, no UPDATE
is performed on the database, but only INSERT
s. As I haven't found any native support by Symfony2 for this requirement, I made up my mind how this could be implemented manually.
Besides the regular ID (primary key) of each entity (e.g. a User
), we add another entity property, e.g. another userID
. So on each change of the user attributes, we could simply INSERT
another row for the user, which then has another ID
, but the same userID
.
The entity could then always be identified by the specific additional entity ID.
But there are a couple of problems that come up with this solution: The regular entity ID is the primary key and therefore the identifier for all relations to this entity. One could also try to create combined primary keys (e.g. ID
plus timestamp
, or ID
plus entityID
), but Symfony2/Doctrine2 is not constructed to support combined primary keys.
So how would you approach to implement a MVCC in Symfony2/Doctrine2? Do you see a way to handle this? Or would you recommend to use a separate history table that keeps track of all changes?