3

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?

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot. Have spent the past hour trying to fix this. This was such a silly mistake on my part.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.