# "rake test" wipes my development database

**URL:** <https://www.ruby-forum.com/t/rake-test-wipes-my-development-database/144884>\
**Category:** Rails\
**Created:** [August 3, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/rake-test-wipes-my-development-database/144884 "2008-08-03T23:00:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [August 3, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/rake-test-wipes-my-development-database/144884/1 "2008-08-03T23:00:37Z")

</div>

When I run “rake test”, I see the following in my development.log:  
DROP TABLE `users`  
CREATE TABLE `users` etc

Sure enough, when I check my development database, all the data is  
gone! But strangely, the test fixtures are loaded into the test  
database, not the development database.

In my database.yml, the production and test databases are clearly set  
to be different, so that’s not the reason.

I’m not setting RAILS\_ENV in the environment I’m running “rake test”  
from, nor is it set to development in any of my config files:  
$ find . | xargs grep RAILS\_ENV  
./config/environment.rb:# ENV[‘RAILS\_ENV’] ||= ‘production’  
./test/test\_helper.rb:ENV[“RAILS\_ENV”] = “test”

If I run “RAILS\_ENV=test rake test” then everything works correctly –  
the development database is not wiped. But surely “rake test” should  
use the test environment automatically?

Any ideas? Or at least ideas on where to look?

Cheers  
Dave.

---

<div class="post-metadata">

**Author:** ![bitsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9de053/32.png) [@bitsmith](https://www.ruby-forum.com/u/bitsmith)\
**Post date:** [August 3, 2008, 11:12pm UTC](https://www.ruby-forum.com/t/rake-test-wipes-my-development-database/144884/2 "2008-08-03T23:12:19Z")

</div>

P.S. This is on the latest 2-1-stable branch.
