5

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?

RyanN
  • 65
  • 3
  • Why would you try to run tests on heroku? – Mike Szyndel Jul 31 '13 at 07:01
  • I'm developing on Nitrous.io and they recommend using Heroku's hosted Postgres solution for the database. I mentioned it above, didn't really explain much about Nitrous though I suppose. I'm just trying to see if there's a solution when developing in "the cloud" using Nitrous.io. – RyanN Jul 31 '13 at 11:40
  • Maybe I'm a moron but I have no idea what this nitrous.io does (and yes, I've looked on their page) – Mike Szyndel Jul 31 '13 at 13:26
  • 1
    @MichaelSzyndel Basically it allows you to provision a box in the cloud and do development on that box through your browser. That way you can develop no matter what computer you're on without having to worry setting up an environment again. They have a in-browser IDE as well. – RyanN Jul 31 '13 at 16:19

2 Answers2

3

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.

Justin Searls
  • 4,789
  • 4
  • 45
  • 56
Greg
  • 1,589
  • 9
  • 14
  • How do I connect a rails app and postgresql via parts? Parts status says postgresql is running but I can rake db:migrate my app. – cpursley Sep 18 '13 at 20:37
  • Nice feature. I'm having the same issue as cpursley though. When I run rake db:create:all I'm getting "could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?" Any suggestions? – RyanN Sep 24 '13 at 02:47
  • I am also having the same issue. `psql` runs perfectly well with a passwordless, default username, but for whatever reason a plain database.yml configuration is unable to make a connection with the error above. :-( – Justin Searls Oct 19 '14 at 14:17
  • A-ha, just discovered it's b/c of how `parts` is building postgres from source and distributing it that the socket is ending up in `/tmp/.s.PGSQL.5432` -- I tried symlinking, but Nitrous does not allow write access to `/var/run` – Justin Searls Oct 19 '14 at 14:26
  • Fixed it! Okay this is entirely bizarre and counter-intuitive, but in order for the postgres adapter to look in `/tmp/` for the socket, you most specify `host: localhost` in your database.yml file. :( – Justin Searls Oct 19 '14 at 14:32
0

According to the Heroku docs, you need to use "heroku pg:reset" in your rake task.

https://devcenter.heroku.com/articles/rake

Scott S
  • 72
  • 2