[Rails] a remote database issue

Dick Davies rasputnik at hellooperator.net
Tue Mar 1 11:22:08 GMT 2005


* Robby Russell <robby at planetargon.com> [0211 22:11]:
> I am trying to connect to a remote postgresql database and am having no
> luck when I run rake.
> 
> For example:
> 
>  rake outputs:
> 
> >pg_dump: [archiver (db)] connection to database "dbname" failed: could
> >not connect to server: No such file or directory

The :clone_structure_to_test can't work remotely, since it sets up pg_dump is set up
to talk to a local socket (another consequence of this is that you need 'trust'
access to the local domain socket when running the unit tests, which makes Baby
Jesus cry if you don't want your Rails coders to be able to login as the postgres
superuser).

I tried fixing this last week, but it's complicated by the fact that
pg_dump doesn't take a password.

One fix (I havent' tried yet) is to use a ~/.pgpass file to code the database settings.
It's not ideal, but then you can:

a) secure the db properly
b) run the tests against a remote db

It's also worth mentioning that the rails db user needs 'create database'
privilege (for the dropdb/createdb operation in the :purge_test_database task to work.

Personally I'd like to see us get away from pg_dump and find another way to
pull the schema from development and drop everything from the test db
(rather than dropdb/createdb).
I'm beginning to think this should be done in the adapter..


> >        Is the server running locally and accepting
> >        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
> >dropdb: could not connect to database template1: could not connect to

> >development:
> >  adapter: postgresql
> >  database: dbname
> >  host: 192.168.1.25
> >  port: 5432
> >  username: webuser
> >  password: password
> 
> Why is it trying to use the sockets when I need it to connect remotely?
> It almost seems like it is ignoring the host: 

-- 
'Ugh, it's like there's a party in my mouth and everyone's throwing up.'
		-- Fry
Rasputin :: Jack of All Trades - Master of Nuns


More information about the Rails mailing list