Difference between revisions of "Revisions"

From SocialStack
Line 12: Line 12:


If you [[generate|generated]] a module then it will be setup to use revisions by default. The [[entities|content type]] (socialstack g Api/Things and then the file Thing.cs) will be a VersionedContent which means it will use revisions if revisions are installed.
If you [[generate|generated]] a module then it will be setup to use revisions by default. The [[entities|content type]] (socialstack g Api/Things and then the file Thing.cs) will be a VersionedContent which means it will use revisions if revisions are installed.
= Making a module not use revisions =
If you know a table will be particularly busy and revisions are not relevant to it, you should opt the type out of revisions. This is done by changing VersionedContent to either UserCreatedContent or simply Content. UserCreatedContent adds things like a creator user ID, created and edited date. Note that on some database engines (other than MySQL) created and edited date are available through other means anyway and don't need to be stored.

Revision as of 20:31, 7 February 2023

Revisions on socialstack are a currently incomplete mechanism for tracking historical changes to the contents of your database. Revisions just work for most content types and will start being stored by simply installing the revisions module.

Getting started

socialstack i Api/Revisions

The first time an API starts with the revisions module installed will result in a lot of new database tables being created. This is because revisions are stored out of your "hot" tables to avoid them clogging up your performance or complicating your queries. The tables that get generated are almost identical to the table that they are revisions of, plus a few extra columns, so querying through historical records is quite straight forward too.

Making a module use revisions

If you generated a module then it will be setup to use revisions by default. The content type (socialstack g Api/Things and then the file Thing.cs) will be a VersionedContent which means it will use revisions if revisions are installed.

Making a module not use revisions

If you know a table will be particularly busy and revisions are not relevant to it, you should opt the type out of revisions. This is done by changing VersionedContent to either UserCreatedContent or simply Content. UserCreatedContent adds things like a creator user ID, created and edited date. Note that on some database engines (other than MySQL) created and edited date are available through other means anyway and don't need to be stored.