Using PostgreSQL with Rails 3, Cucumber & RSpec

Posted on January 05, 2011 in ruby, rails

One thing that tripped me up when trying to set up a new project using PostgreSQL rather than sqlite3, is that when running rake db:test:prepare I got the error message:

/path/to/rake:19:in `<main>'
Couldn't create database for
{"adapter"=>"postgresql", "encoding"=>"unicode",
"database"=>"myproject_test", "host"=>"localhost",
"pool"=>5, "username"=>"moi", "password"=>nil, "min_messages"=>"WARNING"}
rake aborted!
FATAL:  database "test" does not exist

This despite having just run createdb -O moi test

I recreated the database, checked that it was, in fact, there (psql myproject_test, and ran the rake command again. Boom. Same error message.

Turns out the user “moi” was allowed to drop databases, but not create them.

psql myproject_development;
ALTER USER moi CREATEDB;
\q

Et voila.

2 comments

  1. Josh says:

    Thanks, I was pulling my hair out over this issue!

  2. David says:

    Yep. Just crossed this issue today. :] Thanks for posting!

    http://dazedthots.blogspot.com/

Post a comment


(lesstile enabled - surround code blocks with ---)