Add model revisioning
This MR adds model revisioning for every model that has the "versioning": true
attribute declared inside its schema.
e.g. for the Person
model:
{
"name": "Person",
"hidden": false,
"sealed": true,
"version": "0.4",
"source": "PersonBase",
"view": "PersonData",
"versioning": true
...
}
After the service is installed a PersonRevision
(hidden) model will be created, that on update-create will hold the Person revisions, versioning them using SemVer
(minor). First revision will always be 1.0.0, second 1.1.0 etc. Access to the revisions is granted by adding the revisions
association to the Person model, which is also done after service installation.
The revisions are generated by the two listeners (set-initial-object, set-object-revision) that are automatically appended to the existing listeners of the model that requires versioning, in this case Person. Note: If the previous-state-listener
-which is required by the two aforementioned listeners-is not already present in the model, it is auto added (always first in the eventListeners array).
For every nested field of the model, a {NestedFieldType}Snapshot
model is created for the relevant revision model.
Blocking universis#947 (closed)