This morning Nate came into my office with an idea for a plugin that facilitated working with Rails, branches, and migrations. He always picks up on some chatter in IRC and thinks up these good ideas. Later in the day we went to lunch together and talked a little bit more about it. 2 hours later we give you [DbBranch](http://github.com/sevenwire/db_branch).
### The problem
The problem is simple: you're working away in some branch, you refactor some models and drop some fields, you discover a bug and switch back to master to fix it but your application behaves differently because your database is on a different schema version. Now you have to recreate your database, fix the bug, and migrate it up again when switching back to your topic branch. Not very efficient.
### The solution
With DbBranch, each branch will get its own database to work with so you can switch between branches and just pick up where you left off. All that is needed is one simple command `rake db:branch:create`.
### How it works
1 git checkout -b topic_branch
2 rake db:branch:create
3 ./script/generate migration drop_some_fields
4 rake db:migrate
5 git commit -a -v
6 git checkout master
rake db:branch:create will create a new YAML file in config called
database.branch.[branch_name].yml, change the database names to
[application]_[environment]_[branch], create all of the databases defined in the YAML file, load the schema, and prepare the test database. Then you can go on your merry way creating migrations without fear of difficulty when switching between your branches.