Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How revisions control works on quora? Database design

Well, I've seen some plugins to create a versions table to keep track of modifications on specific models, but cant do easily like quora shows

Changing a topic photo on quora

What I have so far is a table like that:

  • id
  • item_type: especifies what model revision refers: "Topic"
  • item_id
  • event: if it was: "edited, added, reverted, removed"
  • who: who triggered the event
  • column: What column in "Topic" the value has changed. "topic.photo_url"
  • new: new value: "http://s3.amazonaws.../pic.png"
  • old old value: ""http://s3.amazonaws.../oldpic.png"
  • revision_rel: points to the past revision
  • timestamp

enter image description here

Someone could give me some help and guidelines with this design? Im worried about performance, wrong columns, missing columns, etc

id  | item_type | item_id |  event  |    who    | column |   new      |    old     | revision_rel |  date
________________________________________________________________________________________________________
1   |   Topic   |    2    |  edit   |   Luccas  |  photo | pic.png    | oldpic.png |    null      |  m:d:y
2   |   Topic   |    2    |  revert |   Chris   |  photo | oldpic.png | pic.png    |      1       |  m:d:y
like image 377
Luccas Avatar asked Jun 25 '12 05:06

Luccas


People also ask

How does version control system work?

Version control enables multiple people to simultaneously work on a single project. Each person edits his or her own copy of the files and chooses when to share those changes with the rest of the team. Thus, temporary or partial edits by one person do not interfere with another person's work.

What is version control system Quora?

A Version Control System is a system that records all the changes made to a set of files or single file. A VCS allows you to call a specific version of a file whenever it is required. This helps in making sure that all the team members of a team are working on the most recent version of the file.

What is database version control?

Database version control is the practice of tracking every change made to the database by every team member. Like application version control, database version control acts as a single source of truth. It empowers you with complete visibility, traceability, and continuous monitoring of the changes in your database.

What are the three types of version control?

The types of VCS are: Local Version Control System. Centralized Version Control System. Distributed Version Control System.


1 Answers

There are some gems available that already do what you are looking for. Have you looked into:

Take a looks at existing gems: https://www.ruby-toolbox.com/categories/Active_Record_Versioning

I am using audited (previously acts_as_audited) for something very similar: https://github.com/collectiveidea/audited

like image 189
Ylan S Avatar answered Sep 22 '22 02:09

Ylan S