Reputation: 51094
I am building a small CMS for training content, on instruction of my client. I have recommended using an existing CMS, but he wants to look at me coding from scratch as well. Most other questions here on implementing a CMS focus on high level CMS features, e.g. templating, editing, SEO, routing etc. but I don't see much at all on the low level aspects, especially versioning of content etc.
To be specific: Are there any components or libraries I can look at for persistance and version management of what I call a ContentItem
in my CMS, or good resources I can consult on doing this myself? A ContentItem
is any large piece of text that should have change tracking, templated fields etc. E.g. standard emails, blog posts, training content, test answers, etc.
Pointers to something I could use for change tracking at Entity Framework level would be a bonus.
Upvotes: 0
Views: 204
Reputation: 93454
It's extremely simple to add versioning to any database table. Just add an additional field for version, this can be a datetime, timestamp, or even just a sequence number that you add one to. You make this a composite primary key with your exiting key (or even just a unique constraint) and you're golden. The rule is, all updates are inserts.
It's really that simple. Then in your queries you just always get the most recent version by default (doing a TOP 1 with an order by decending works well)
Upvotes: 1