Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the standard or best way to deal with database branching with Mercurial or Git branches?

This has been a big question mark on my mind.

I'm moving to Mercurial or Git very soon for my web software, and sometimes my branches require significant database changes which other branches should not see. This, I can't always share the same database for my branches.

Is there some standard way of dealing with database changes for branching and cloning? What do you all do? I'm using MySQL.

like image 716
Chad Johnson Avatar asked Mar 25 '10 17:03

Chad Johnson


3 Answers

Using a database changset tool can be really helpful. I've used liquibase (http://www.liquibase.org), at work to manage version control for the db. I would warmly recommend that tool to anyone. Liquibase does support changesets, with configurable rollback scenarios. However, it is a tool for managing the schema, not the actual data. I wouldn't try to use it to keep the table data up-to-date.

However, I still feel that your best bet is to use liquibase, and have different schemas, for different source branches.

like image 170
Kai Inkinen Avatar answered Oct 19 '22 19:10

Kai Inkinen


I don't have an answer for you, but I did come across a recent article that might be relevant: Why your database version control strategy sucks and what to do about it, Part I

like image 20
Kylotan Avatar answered Oct 19 '22 18:10

Kylotan


For handling cloning, your database should be designed to be multi-user.

For changes in schema, commit changes to the schema for that branch as part of the respository.

Then you have to make up your mind, for each schema, do you run multiple tablespaces in one database, multiple databases, etc.? Then commit a pointer to the correct one as part of the installation configuration in that branch.

like image 2
kmarsh Avatar answered Oct 19 '22 19:10

kmarsh