How to set up datatables for auto-revisioning

From CTRNet Wiki
Jump to: navigation, search

Any datatable can be set up for auto-revisions by creating a specific "_revs" datatable.

Make an exact copy of any datatable (just the structure, not the data), and name it exactly the same as the original except with the suffix "_revs". For example, a datatable named "participants" will have a copy named "participants_revs".

In your new "_revs" datatable, change to any/all key, unique, and auto-incrementing fields to normal. Then create two new fields: an INT field named "version_id" and a DATETIME field called "version_created". The new "version_id" will be the unique key of the datatable, and should be auto-incrementing.

From that point on, a behaviour added to the /app/app_model.php file will "see" any add, update, or delete Model action, and create a revision in the associated "_revs" datatable. Any datatable without a behaviour added will not get a revision.

There is no ATiM2 interface for accessing these revisions.

For more information, visit the behaviour's CakePHP Bakery page

Personal tools