So I have recently migrated to postgresql, and have been having issues with my test database creation. Whenever I run a rake task it seems to destroy my ability to access the test database that I have created. For example, if I run the following command

createdb -Ouser -Eutf8 example_test

I can run tests perfectly, however if I run a rake task I will get the following error:

.rvm/gems/ruby-1.9.2-p180@standard/gems/activerecord-3.1.0/lib/active_record/connection_adapters/postgresql_adapter.rb:991:in `initialize': FATAL: database "example_test" does not exist (PGError)

If I create a new test database like so:

createdb -Ouser -Eutf8 example2_test

Everything will work again, until I have to run a rake task. Does anyone know what this issue could be?

share|improve this question

72% accept rate
feedback

2 Answers

up vote 1 down vote accepted

Fixed the bug, by finding the following blog post about the topic: http://katrinaowen.com/2011/01/05/using-postgresql-with-rails-3-cucumber-and-rspec In short, this was a bug with creating databases with rspec installed, view the link and run the commands to get it to work on your system.

share|improve this answer
feedback

Perhaps you can look at log/development.log to see why the database is being dropped? And look at the rake task code itself to see what it is doing.

Usually the test database is generated via rake db:test:prepare based on config/database.yml

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.