Martinicity: Tag apptrain Mike Blake tag:www.martinicity.net,2005:Typo Typo 2007-02-16T03:30:13+00:00 Mike Blake urn:uuid:7d6f994d-0845-41c7-a8ea-09a9157c94db 2007-02-07T21:14:00+00:00 2007-02-16T03:30:13+00:00 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>