Deeby¶ ↑
Description¶ ↑
Tasks to switch your Rails database configuration for a single Rake run. Useful when you’re targeting more than one database engine.
I use this for Rails, but it should work in any framework that uses a config/database.yml file.
Examples¶ ↑
Create a database.[DB].yml
file for each extra DB setup you might want to use. For example:
$ ls config/database.*.yml config/database.pg.yml config/database.sqlite.yml
These files look remarkably similar to database.yml
, they’re just written for a different DB engine. Deeby looks for files that match this pattern and generates prefix Rake tasks for each alternative DB file you’ve created.
For the example above, Deeby will generate tasks called db:pg
and db:sqlite
. These tasks swap out database.yml
for the scope of the Rake run and restore it when you’re finished.
Let’s say you develop on MySQL by default, but you’re also deploying (or transitioning) to Postgres. Once you’ve written database.pg.yml
, here’s how it works out:
# runs the tests against your normal setup (MySQL) $ rake test # runs the tests against your Postgres setup $ rake db:pg test
…and things are back to normal afterward. Don’t forget to run db:create
and db:reset
(or whatever) with the prefix task when you’re setting things up initially:
# new Postgres setup $ rake db:pg db:create db:reset
Installation¶ ↑
$ gem install deeby # in your Rakefile require "deeby"
License¶ ↑
Copyright 2009 John Barnette (jbarnette@rubyforge.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.