The changelog can be activated by setting the structr.conf switch application.changelog.enabled to true. A Structr instance started with changelog enabled keeps a record of every modification of an entity. There are different kinds of actions (called verb) for which a record is kept.

The changelog itself can be retrieved using the builtin changelog() function. The changelog is written to disk at changelog.path in a subfolder n for nodes and r for relationships.
If user-centric changelog (application.changelog.user_centric.enabled) is enabled the changelog is written to the subfolder u. In older versions of structr the changelog was written to the structrChangeLog property of a node.
The following tables show the possible keys/values of modification records. Modification records are stored as a JSON string. (see the example below)

Verb Event type Keys in changeset
create Creation of an object verb,time,userId,userName,target
delete Deletion of an object verb,time,userId,userName,target
link A relationship to/from another object has been created verb,time,userId,userName,target, rel
unlink A relationship to/from another object has been removed verb,time,userId,userName,target, rel
change One of the properties of the object has been changed verb,time,userId,userName,key, prev, val
Key Content
verb type of changelog event (One of create, change, delete, link, unlink)
time Timestamp of the change (ms since epoch)
userId id of the user, 00000000000000000000000000000000 for SuperUser, null for anonymous
userName name of the user who triggered the modification
target id of the target node of the new or deleted relationship
relId id created/deleted relationship
rel relationship type of the created/deleted relationship
relDir relationship direction of the created/deleted relationship (in/out)
key Property key of the modified property
prev Previous value of the modified property
val New value of the modified property
{"time":1455195862431,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"change","key":"name","prev":null,"val":"My new name"}
{"time":1455195903852,"userId":"f02e59a47dc9492da3e6cb7fb6b3ac25","userName":"admin","verb":"change","key":"name","prev":"My new name","val":"New Name"}
About this article
Last change 2019-03-27
Topics ExperimentalStructr 2.0