I’d like to use postgresql with unix domain sockets for
testinng/development
to avoid mismatches when tests from multiple working copies are run
concurrently.
I can almost get what I want with the following entry in
config/database.yml:
Unfortunately, the path is specified absolutely here. So when I check
out
two working copies of my application and run the tests in parallel on
both
copies, the database will get mangled.
So I am looking for a possibility to specify the directory relatively.
Maybe
host: `pwd`/db/pgdata
or
host: #{RAILS_DIR}/db/pgdata
or something.
Can this (or something similar) be done? Any suggestions?
I’d like to use postgresql with unix domain sockets for
testinng/development
to avoid mismatches when tests from multiple working copies are run
concurrently.
I can almost get what I want with the following entry in
config/database.yml:
Unfortunately, the path is specified absolutely here. So when I check
out
two working copies of my application and run the tests in parallel on
both
copies, the database will get mangled.
So I am looking for a possibility to specify the directory relatively.
Maybe
host: `pwd`/db/pgdata
or
host: #{RAILS_DIR}/db/pgdata
or something.
Can this (or something similar) be done? Any suggestions?
Since config/database.yml is read through ERB, you can do stuff like
host: <%= RAILS_DIR %>/db/pgdata
or
host: <%= hostname %>
Check vendor/rails/railties/lib/initializer.rb, this is from Rails 2.3:
# Loads and returns the contents of the
#database_configuration_file. The
# contents of the file are processed via ERB before being sent
through
# YAML::load.
def database_configuration
require ‘erb’
YAML::load(ERB.new(IO.read(database_configuration_file)).result)
end