Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run Ruby on Rails tests on Heroku's hosted Postgres databases

I'm currently evaluating Nitrous.io and liking what I'm seeing so far. I've currently got a few databases for testing and development running on Heroku's hosted Postgresql service as well. I'm running into some issues when running tests though, and I'm hoping somewhere here may have a solution.

When I run rake db:test:prepare I'm getting the error:

 FATAL:  permission denied for database "postgres"                                                                                                                  
 DETAIL:  User does not have CONNECT privilege.   

From what I've read elsewhere, that's trying to DROP the database, but Heroku's hosted databases don't allow that. Does anyone out there know how to run Rails tests on Heroku's Postgresql?

like image 634
RyanN Avatar asked Oct 22 '22 04:10

RyanN


1 Answers

Nitrous.IO has released a package manager which will allow you to install Postgres within your Nitrous box. This can be used for your test database as well as your development database if needed:

https://github.com/action-io/autoparts

This also requires that you are using a Nitrous box is running version "bran" or later (see README). You may need to terminate/create a new box if you are running on version "arya".

To use autoparts, run parts search to see all of the packages available.

To install postgresql within the Nitrous box, run the following command:

parts install postgresql

Make sure that your config/database.yml file explicitly sets host: localhost for each database you wish to connect to, or else the pg adapter will fail to find the socket it needs to connect to.

like image 187
Greg Avatar answered Oct 30 '22 02:10

Greg