ryanthompson - 1 month ago

The outline of this feature would be to basically allow versioning of model entries. My thought is to add a version column to the models and auto-scope the query similar to trashable and soft deletes in laravel.

We could sort by version descending first and use the latest inside the query builder. Index the column for optimization. Then save / save as new version would be options in the forms? Or we could just always save to new version?

The purpose of this would be to allow you to roll back to an earlier state of the entry you modified. This is huge with larger entities like banks and legal industry businesses.

edster - 1 month ago

I assume you would have a versioning table with poly back to models? and maybe a data column with a jsoned entry? I don't want to see version tables for every fucking model.

ryanthompson - 1 month ago

We will be able to cherry pick values from older versions this way as well if we wanted to.

ryanthompson - 1 month ago

@edster the idea would be to add a single version column on the entries table.


For example.

edster - 1 month ago

Ah, so as an example, I had a page with 3 fields saved. I resave the page changing one field, I now have 2 entries in the table, V1, V2. What happens if I hit save, but didn't change any fields? Am I getting a V3 row as well?

I don't know about others, but I would rather see the base tables behave the same, with a pre saved cache being saved as a json into a version table with a poly to the record.

Keeps the table cleaner, also what happens if I delete a page/trashed entry, are we deleting the old versions as well?

frednwt - 1 month ago

Then save / save as new version would be options in the forms? Or we could just always save to new version?

Why not having a $autoversion = true / false? So we can pick?

ryanthompson - 1 month ago

@frednwt that's not a bad idea at all.

ryanthompson - 1 month ago

I think something closer to this will be a tighter solution: https://github.com/mpociot/versionable

Problem with column is inefficient when querying and make returning sets of entries (latest) very tough. So definitely need a table for it.

Need to think about UI for it. I guess something along the lines of the fields and others type controllers and builders.

william - 1 month ago

This is something i would really love.

finnlesueurgmailcom - 2 weeks ago

Just want to +1 this.

I'm making a site for a volunteer organisation and often there are a number of people who have edit access to various pages. It'd be really swell to have be able to see revision history for pages.

ryanthompson - 2 weeks ago

Almost done with this feature - next to integrate with some starter addons / document. This will be in PyroCMS v3.5 on Streams Platform v1.4

ryanthompson - 2 weeks ago

Here is a simple example of the versioning in action: https://youtu.be/RSuaEdJspoA