How to log changes with ability to rollback?

let's say there is a simple diagram many-to-many
articles, article_tags, tags

It is necessary that every change has loirevalley + ability to undo in 1-3 clicks

field change article, and svyazanykh with her tags.

For example was the entry:
article.title = "hello world1", article.body = "the Text records1", article.published_at = 2016-11-20, article.user_id = 1;
a bunch article_tags (1,1), (1,2)
Another user has modified the article and she's already
article.title = "hello world2", article.body = "the Text записи2", article.published_at = 2016-11-20, article.user_id = 3;
a bunch article_tags (1,1), (1,3), (1,4)
July 2nd 19 at 13:32
6 answers
July 2nd 19 at 13:34
Solution
July 2nd 19 at 13:36
change what?
field change article, and svyazanykh with her tags - Adolfo.Wintheiser commented on July 2nd 19 at 13:39
July 2nd 19 at 13:38
Change what You want to log? Database or files? If a file - GIT.

If base, then the migration or perhaps Git+migration.

If the data in the database, the backup of the database (if the database is small, then a backup in GIT).
field change article, and svyazanykh with her tags - Adolfo.Wintheiser commented on July 2nd 19 at 13:41
He meant to make the story related data. That was the magazine that was then, was such, and then other - Adolfo.Wintheiser commented on July 2nd 19 at 13:44
: I think the only sane way in this situation is either a migration of laravale, or dump the database without data (dump of the structure) in a GIT repository. In principle, if no data, I think migration is perfect. - jules_Nolan10 commented on July 2nd 19 at 13:47
Again you do not understand.

First the user has selected 5 documents, and then he chose the 28 selected. Where there's a story that before he was five. Or similarly, the change log tags to the article. It was 1,2,3, and 7 became 5,3,2,8,9 and then to 4.3. And we need that log - Salvado commented on July 2nd 19 at 13:50
: Then it is a whole database dump must, I think, along with the data. In the repository... Other logging I can hardly imagine... Although you can certainly certainly pick the log of the database itself, but it either way it leads the user wants that or not... - jules_Nolan10 commented on July 2nd 19 at 13:53
July 2nd 19 at 13:40
For example, to keep the 2 tables
currentItem
itemHistory

Before writing to currentItem its contents, a new entry in itemHistory
And to roll back as well
July 2nd 19 at 13:42
This raises the question of data integrity. If you remove one of the related objects that you used in the past - it will be impossible to restore the communication log. And so I'd keep it all in one table with the revision number. That is, each time would duplicate connection when it is modified and written to the global scope, is to fetch this regard.
July 2nd 19 at 13:44
Maybe it would be easier to put a trigger on update/alter table, which will write the "old" values in a "table of archival values"?

Find more questions by tags PHPMySQLLaravel