今天,和往常一样,我尝试制作 混合 ecto.migrate 在我的 Phoenix 应用程序中,意外地发现了以下错误:
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
我在开发环境中运行测试或提供页面时没有这样的错误,只有当我运行 混合 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"} 开关,一切都按预期工作。
最佳答案
将此添加到 config/config.ex
config :adah, :ecto_repos, [Adah.Repo]
关于elixir - 使用 Ecto 2.0.0-rc.0 并执行 ecto.migrate 时出现奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36680871/