Martinicity: Tag apptrain http://martinicity.net/articles_controller.rb/tag?tag=apptrain en-us 40 Mike Blake Rails SafetyNet <h2><b>Curent Mood:</b> Bored with Deleting the Production Database</h2> <p> <p>I thought I was the only clown working on Rails projects and ignoring the <a href="http://dev.rubyonrails.org/svn/rails/applications/plugins/config/database.example.yml">warning in config/database.yml</a> and using rake to wipe out perfectly good databases. But I&#8217;ve seen it happen to others now, and enough&#8217;s enough. So I created the <h3>SafetyNet Plugin</h3>.</p> <p>You can install Safety Net in your app, by running</p> <code> ruby script/plugin install svn://rubyforge.org/var/svn/apptrain/trunk/vendor/plugins/safety_net </code> <p>That&#8217;s it. Now, If the <b>test</b> database points to the same database as <b>development</b> or <b>production</b> running rake will display the following message:</p> <p>!<a href="/images/safety_net.png">safety net</a></p> <pre> rake aborted! The name of your test database matches production or development. </pre> <h3>How it Works</h3> <p> <p>Purging the poor innocent database is prevented in two ways.</p> <p>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.</p> Wed, 07 Feb 2007 21:14:00 +0000 urn:uuid:7d6f994d-0845-41c7-a8ea-09a9157c94db Mike Blake http://martinicity.net/articles/2007/02/07/safety-net Create safetynet safetynet apptrain rails plugin rake rails test database