Answer the question
In order to leave comments, you need to log in
How to log changes with the ability to roll back?
let's say there is a simple scheme many-to-many
articles, article_tags, tags It is
necessary that each change be logged + the ability to roll back in 1-3 clicks
to change the article fields, and the tags associated with it.
Let's say there was an entry:
article.title = "hello world1", article.body = "Entry text1", article.published_at = 2016-11-20, article.user_id = 1;
article_tags binding (1,1), (1,2)
Another user modified the article and it is already
article.title = "hello world2", article.body = "Post text2", article.published_at = 2016-11-20, article. user_id = 3;
bundle article_tags (1,1), (1,3), (1,4)
Answer the question
In order to leave comments, you need to log in
What changes do you want to log? Databases or files? If files - then GIT.
If bases, then migrations or maybe Git+migrations.
If there is also data in the database, then backup the database (if the database is small, then backup in GIT).
For example, keep 2 tables
currentItem
itemHistory
Before writing to currentItem its contents with a new entry in itemHistory
And rollback in the same way
This raises the issue of data integrity. If you delete one of the linked objects that was used in the past, then it will no longer be possible to restore this link from the log. And so I would store everything in one table with the revision number. That is, each time I would duplicate the connection when it changes and write a global scope to select this connection.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question