tomciopp
tomciopp

Reputation: 2742

rails test database errors with postgresql on OSX

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?

Upvotes: 3

Views: 997

Answers (2)

tomciopp
tomciopp

Reputation: 2742

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.

Upvotes: 4

rocketscientist
rocketscientist

Reputation: 2488

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

Upvotes: 0

Related Questions