Hello, I try to use a different repo for each data model : User, Comment and News.
I created a separate file for each repo like this :
# file repo_news.ex
defmodule ScienceNews.NewRepo do
use Ecto.Repo,
otp_app: :science_news,
adapter: Ecto.Adapters.Postgres
end
# file repo_comment.ex
defmodule ScienceNews.CommentRepo do
use Ecto.Repo,
otp_app: :science_news,
adapter: Ecto.Adapters.Postgres
end
# file repo_user.ex
defmodule ScienceNews.UserRepo do
use Ecto.Repo,
otp_app: :science_news,
adapter: Ecto.Adapters.Postgres
end
config.exs :
config :science_news,
ecto_repos: [
ScienceNews.NewRepo,
ScienceNews.CommentRepo,
ScienceNews.UserRepo
]
application.ex :
children = [
# Start the Ecto repository
ScienceNews.NewRepo,
ScienceNews.CommentRepo,
ScienceNews.UserRepo,
However running this I get this error :
[error] GenServer #PID<0.455.0> terminating
** (RuntimeError) connect raised KeyError exception: key :database not found. The exception details are hidden, as they may contain sensitive data such as database credentials. You may set :show_sensitive_data_on_connection_error to true when starting your connection if you wish to see all of the details
(elixir 1.10.4) lib/keyword.ex:399: Keyword.fetch!/2
(postgrex 0.15.5) lib/postgrex/protocol.ex:92: Postgrex.Protocol.connect/1
(db_connection 2.2.2) lib/db_connection/connection.ex:69: DBConnection.Connection.connect/2
(connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
(stdlib 3.13) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
I restarted the server and I tried :
mix ecto.migrate
mix ecto.migrate -r ScienceNews.UserRepo
I test in local.
Have I missed some configuration ? Is this possible ?
Thank you so much for your help