Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rake aborted! ERROR: must be owner of database

I am working through Michael Hartl's excellent tutorial but when trying to prepare the test database with the command: bundle exec rake db:test:prepare I get this error message:

ERROR: must be owner of database sample_app_test...

which I never got when using the development database, because I had created the following database role for my Rails app:

CREATE ROLE demo_app WITH CREATEDB LOGIN

(this is using Postgresql)

Does anyone understand why this is failing in the test environment? TIA...

like image 412
rixter Avatar asked Aug 26 '11 21:08

rixter


2 Answers

Did you ensure the ownership of the test DB? try running the \l command on Postgres console client and check the ownerships. you can also try the following query:

ALTER DATABASE sample_app_test OWNER TO demo_app;

like image 180
Seth Malaki Avatar answered Nov 05 '22 15:11

Seth Malaki


First post, writing this down for posterity. I was having the same problem but was able to fix it. You just have to make sure you were/are signed in as a superuser when you create your databases (or the one that is throwing the error).

I was logging into psql with this code:

sudo sudo -u postgres psql 

And created my databases. This is bad. You want to log in with these superuser credentials:

sudo su - postgres

And then after you're logged in to postgres:

psql 

Then create your databases. You can kill your old databases with the command

DROP DATABASE "database_to_drop";

Recreate them and you should be good to go!

like image 3
LearningRuby Avatar answered Nov 05 '22 14:11

LearningRuby