Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any best way to implement version control for database content?

I'm currently writing a posting website that needs to have a version control on posts. I just don't know how I should implement this, in term of database and technique, in order to save and control the post.

Is there anyone experienced with this who can help me?

I've seen that Wordpress does version control only in 1 table, which is POST. I also suggest doing the same since it's trouble to write into 2 tables with the same amount of data and fields.

like image 640
DucDigital Avatar asked Dec 10 '09 01:12

DucDigital


People also ask

How version control is implemented in database?

Ensure the version control repository acts as the single source of truth. Ensure the deployment script being executed knows environment status when the script is executing. Ensure the deployment script handles and merges conflicts. Generate a deployment script for only relevant changes.

What is DB versioning?

Versioning a database means sharing all changes of a database that are neccessary for other team members in order to get the project running properly. Database versioning starts with a settled database schema (skeleton) and optionally with some data.

Does Git work with database?

Git has a database "Committed means that the data is safely stored in your local database." "The Git directory is where Git stores the metadata and object database for your project." GitHub also provides access to a git database stored on GitHub via an API, aptly named "Git database".

What is database VCS?

The VCS is a mechanism to ensure that the database source that has been stored is identical to what was released. Before deploying a new database version, the team can compare the target database with the source scripts for that database version, in the VCS.


1 Answers

I know that stackoverflow stores deltas between versions. What I have seen others do is set up another table like the first one but with an author and a version or timestamp on it. You can push records over to the other table using a database trigger so you don't have to worry too much about making the change at the application level.

If you would like to use only one table then I would suggest adding the author, timestamp and a iscurrent flag. The flag isn't really needed since you can select the max version number but it will make your queries much easier. Set the flag only when the row is the highest version number. You can still use a trigger to populate the rows but watch out or you might end up in a loop of update triggers.

like image 124
stimms Avatar answered Nov 15 '22 18:11

stimms