I'm creating a clojure project using Leiningen with environ to keep a uri for managing a database connection in either the projects profiles.clj
or an environment variable, and I want to try using lein-flyway to manage db migrations.
Lein-flyway has its own configuration specifying the database uri, and I'd rather not force my coworkers to put the connection uri in two places in their configuration.
Currently, profiles.clj
is not checked in and looks something like this:
{:profiles/dev
{:env {:database-url
"jdbc:postgresql://localhost/project?user=$USER&password=$PASS"}}
:profiles/test
{:env {:database-url
"jdbc:postgresql://localhost/project_test?user=$USER&password=$PASS"}}}
And I would like to add an entry like the following, either to my :profiles/dev
map in my profiles.clj
or to my :project/dev
map in my project.clj
.
:flyway {:url ~(get-in profile-map [:profiles/dev :env :database-url])}
It seems like I might be able to slurp the profiles.clj in my project.clj and extract the key there, and interpolate it into the project map at the appropriate place. Is that the best option? Is there an easier way to reuse a value like this?