public
Description: Rails plugin to play nice with git branching and databases.
Homepage: http://sevenwire.com/blog/2008/12/03/introducing-db-branch.html
Clone URL: git://github.com/sevenwire/db_branch.git
shame (author)
Sun Jan 11 15:23:34 -0800 2009
sevenwire (committer)
Tue Jan 13 15:34:12 -0800 2009
commit  3dc68d2293c2c323a452fa4b4fb8b989a1345086
tree    c8c7df0bb352b9e190781bc0fe1fe4bf4335b80a
parent  459298fe4614a29d643b6ae09717e4419fedde61
name age message
file MIT-LICENSE Wed Dec 03 11:34:05 -0800 2008 Initial commit. [brandonarbini]
file README.markdown Loading commit data...
file Rakefile Wed Dec 03 11:34:05 -0800 2008 Initial commit. [brandonarbini]
file init.rb Wed Dec 03 12:37:23 -0800 2008 Initial infrastructure for loading a branch spe... [nate]
directory lib/ Wed Dec 03 12:39:13 -0800 2008 Nate being anal and also removing extentions fo... [nate]
directory tasks/
directory test/ Wed Dec 03 11:34:05 -0800 2008 Initial commit. [brandonarbini]
README.markdown

DB_BRANCH

Rails plugin to play nice with git branching and databases. Loads a branch-specific database YAML file allowing you to migrate in branches without affecting the database of other branches.

More information:
http://sevenwire.com/blog/2008/12/03/introducing-db-branch.html http://cryingwhilecoding.com/2009/1/11/easily-manage-db-changes-between-branches-in-git

Usage

First, you should have your db backed up. Just saying.

By default, it will run setup, config, and create_clone tasks so you'll end up with a running copy of your existing db for your branch

rake db:branch

Update the db again? The clone task will drop and recreate the db and reload it from the original

rake db:branch:clone

Just want a clean db without the data? create_empty will create the config and just load the db from the schema

rake db:branch:create_empty

No longer need the branched db? purge will remove the branched databases and config

rake db:branch:purge

Branch database config files are named database.branch.[branch_name].yml. The database names for the branch are renamed as [application]_[environment]_[branch] or [databasename]_[branch] if the originals where not named using a [application]_[environment] convention.

You can alter which database is used for the cloning or schema loading by setting the RAILS_ENV variable

rake db:branch:clone RAILS_ENV=development

But can it go to Eleven?

The only thing I can imagine making this any better is possibly finding a way of using gits hooks to automatically run rake db:branch when creating a new branch and rake db:branch:purge when deleting a branch. That'd be pretty hot.

Authors

Nate Sutton (nate@sevenwire.com)
Brandon Arbini (brandon@sevenwire.com)
Mike Vincent (mike@cryingwhilecoding.com)