3

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?

adambaker
  • 31
  • 5

1 Answers1

0

I don't know if I understand correctly but maybe this help you.

Édipo Féderle
  • 4,169
  • 5
  • 31
  • 35
  • 1
    Composite profiles don't help. That will merge two different profiles. I want to have my database url appear in two different key paths inside my profile; I don't see a way to do this without either duplicating the url in the configuration, or using some compile time trickery with the read-eval macro. – adambaker Jul 15 '16 at 23:27