Hello fellow elixir+ecto enthusiasts,
A question to the people familiar with Ecto and its intended use for a Repo intended to be shared between different applications.
In our case we have a series of applications (that are not part of an umbrella project) that we intend to run on different machines. However, two of them are using a Repo that we would like to make available to both. So here is our situation:
App Core (defines a Model.Repo with all the necessary logic)
App Prez (wants to use Model.Repo from App Core as well)
For App Prez we've added App Core to the applications that need to run in mix.exs. However, this doesn't compile because the code in App Core that is defined within the deps folder can't find its configuration for the Repo within that deps folder:
== Compilation error on file lib/model/repo.ex ==
** (ArgumentError) missing :adapter configuration in config :core, Model.Repo
lib/ecto/repo/supervisor.ex:37: Ecto.Repo.Supervisor.parse_config/2
lib/model/repo.ex:6: (module)
(stdlib) erl_eval.erl:669: :erl_eval.do_apply/6
By copying that configuration data inside the config.exs of App Prez as follows (prez/config/config.exs) we get it to compile:
config :core, :app_repo, Model.Repo
config :core, Model.Repo,
adapter: Ecto.Adapters.Postgres,
config :prez,
xxx: yyy
Now we have two copies of this configuration data:
1. in the core project
2. in the prez project
This seems clumsy to us. Is there a better way?
How would people share the functionality of a database with its Ecto model between different applications using only one copy of the source code and its configuration?
Thank you for you insights!
Annard