I'd like my Play app to use different databases for test, local and production (production is Heroku) environments.
In application.conf
I have:
db.default.driver=org.postgresql.Driver
%dev.db.default.url="jdbc:postgresql://localhost/foobar"
%test.db.default.url="jdbc:postgresql://localhost/foobar-test"
%prod.db.default.url=${DATABASE_URL}
This doesn't seem to work. When I run play test
or play run
,
all DB access fails with:
Configuration error [Missing configuration [db.default.url]] (Configuration.scala:258)
I have a few questions about this:
In general, I'm a little confused about how databases are configured in Play: it looks like there's plain
db
,db.[DBNAME]
anddb. [DBNAME].url
and different tutorials make different choices among those. Certain expressions that seem like they should work (e.g.db.default.url = "jdbc:..."
fail with an error that a string was provided where an object was expected).I've seen other people suggest that I create separate
prod.conf
,dev.conf
andtest.conf
files that each includeapplication.conf
and then contain DB-specific configuration. But in that case, how do I specify what database to use when I runtest
from the Play console?Is the
%env
syntax supposed to work in Play 2?What's the correct way to specify an environment for
play test
to use?
%prod
tips were for Play 1.x? Thanks for the examples. I actually have the dev/prod configuration issue worked out at this point. My remaining question is still: how do I configure Play to use a different environment when running the test suite? – Sogdiana