Are there general version control options in the database?

I have little experience using SVN in my development projects, and I have the same little experience working with relational databases. I know basic concepts such as tables and SQL statements, but I am far from being an expert.

What I would like to know is if there are general version control systems, such as SVN, but they work with the database, not with the files. I would like the same functions that SVN have to do with the ability to create branches, create tags and merge branches together. Instead of the version number associated with the file repository version, it will be associated with the database version.

Are their universal solutions available that can add this functionality regardless of the actual database schema? I would be interested in solutions that work with MySQL or MS SQL Server.

I should also clarify that I am trying to control data versions, not a schema. I would expect the circuit to remain constant. So it really seems that I want to create a log of all the INSERT, UPDATE and DELETE queries that sent the database between each version of the data. Thus, any version can be recreated by resubmitting all SQL statements that have been saved to the desired version.

+4
source share
4 answers

You can script all your DDLs, stored procedures, etc. into plain text files.

Then you can simply use SVN to control database versions.

+1
source

I never found a solution that works the same as Subversion, but here are a few things I did that helped:

  • Create scripts that will create the schema and populate any source data. Then do a script update for each change after that. This is a fairly manual process, but it works. There are additional things that help keep the current version number in a table in db and make sure the scripts are idempotent .

  • Save the full version of db in Subversion. This is usually not too good for me if there is a lot of data or it often changes. But in some projects it can work.

+1
source

I can think of two things:

  • http://www.liquibase.org/ - Provides a way to overall manage database changes. Creates files that are transferred to the original control, and helps manage changes in different development databases, etc.
  • http://www.viget.com/extend/backup-your-database-in-git/ - this describes the strategy for backing up the database to the original control, but the same strategy can only be used on the schema. In this scheme, the database will be in a separate area from your main code. (This can be used with other version control systems.)
0
source

I save and support scripting in my version control system.

0
source

Source: https://habr.com/ru/post/1303589/


All Articles