今天,我经常在我的凤凰应用程序中尝试混合ecto.migrate ,并出人意料地发现了以下错误:
warning: could not find repositories for application :adah.
You can avoid this warning by passing the -r flag or by setting the
repositories managed by this application in your config files:
config :adah, ecto_repos: [...]
The configuration may be an empty list if it does not define any repo.
** (Protocol.UndefinedError) protocol Enumerable not implemented for :ok
(elixir) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir) lib/enum.ex:116: Enumerable.reduce/3
(elixir) lib/enum.ex:1486: Enum.reduce/3
(elixir) lib/enum.ex:609: Enum.each/2
(mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
我的代表是:
phoenix_ecto: 3.0.0-rc.0
ecto: 2.0.0-rc.0
...
我的配置文件包含以下行:
dev.ex:
# Configure your database
config :adah, Adah.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "adah_dev",
hostname: "localhost",
pool_size: 10
test.ex:
# Configure your database
config :adah, Adah.Repo,
adapter: Ecto.Adapters.Postgres,
username: System.get_env("POSTGRES_USER") || "postgres",
password: System.get_env("POSTGRES_PASSWORD") || "postgres",
database: System.get_env("POSTGRES_DB") || "adah_test",
hostname: System.get_env("POSTGRES_HOST") || "localhost",
pool: Ecto.Adapters.SQL.Sandbox
我在开发环境中运行测试或提供页面时没有出现此类错误,只有在我运行 mix ecto.migrate 时。
那么......我应该将什么添加到配置文件中或传入 -r 标志?
更新:我相信有一个错误,它对应于phoenix-3.0.0-rc.0或ecto-2.0.0-rc.0包,因为当我使用{:ecto,“== 2.0.0时-beta.2“,:phoenix_ecto,”3.0.0-beta.2“}开关,一切都按预期工作。
答案 0 :(得分:9)
将此添加到config / config.ex
config :adah, :ecto_repos, [Adah.Repo]