Rails SafetyNet
Posted by Mike Blake Wed, 07 Feb 2007 21:14:00 GMT
Curent Mood: Bored with Deleting the Production Database
I thought I was the only clown working on Rails projects and ignoring the warning in config/database.yml and using rake to wipe out perfectly good databases. But I’ve seen it happen to others now, and enough’s enough. So I created the
SafetyNet Plugin
.You can install Safety Net in your app, by running
ruby script/plugin install svn://rubyforge.org/var/svn/apptrain/trunk/vendor/plugins/safety_net
That’s it. Now, If the test database points to the same database as development or production running rake will display the following message:
rake aborted! The name of your test database matches production or development.
How it Works
Purging the poor innocent database is prevented in two ways.
1. By adding a prerequisite check to the rake script that normaly performs this task. 2. By modifying the fixtures method on ActiveRecord to avoid the same fate when running individual tests with the ruby command.

