Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there generic options for version control within a database?

I have a small amount of experience using SVN on my development projects, and I have just as little experience with relational databases. I know the basic concepts like tables, and SQL statements, but I'm far from being an expert.

What I'd like to know is if there are any generic version control type systems like SVN, but that work with a database rather than files. I would like the same kind of features you get with SVN like the ability to create branches, create tags, and merge branches together. Rather than a revision number being associated to a version of a file repository it would be associated with a version of the database.

Are their any generic solutions available that can add this kind of functionality independent of the actual database schema? I'd be interested in solutions that work with MySQL or MS SQL Server.

I should also clarify that I'm trying to version control the data not the schema. I would expect the schema to remain constant. So really it seems like I want a way to create a log of all the INSERT, UPDATE, and DELETE requests sent the the database between each version of the data. That way any version could be recreated by resending all the SQL statements that have been saved up to the desired version.

like image 341
Eric Anastas Avatar asked Nov 06 '22 15:11

Eric Anastas


2 Answers

You can script all your DDL, stored procedures and such to regular text files.

Then you can simply use SVN for database versioning.

like image 66
Oded Avatar answered Nov 11 '22 14:11

Oded


I've never found a solution that works as well as Subversion, but here's a few things I've done that have helped:

  1. Make scripts that will create the schema and populate any initial data. Then make an update script for each change after that. It's a fairly manual process, but it works. There's extra things that help like storing the current version number in a table in the db and making sure that the scripts are idempotent.

  2. Store the full development db in Subversion. This doesn't usually work out too well for me if there is a lot of data or it is frequently changed. But in some projects is could work.

like image 41
David Hogue Avatar answered Nov 11 '22 13:11

David Hogue