Val*_* T. 13 elixir ecto phoenix-framework
今天,我经常尝试在我的Phoenix应用程序中混合使用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
Run Code Online (Sandbox Code Playgroud)
我的代表是:
phoenix_ecto: 3.0.0-rc.0
ecto: 2.0.0-rc.0
...
Run Code Online (Sandbox Code Playgroud)
我的配置文件包含以下行:
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
Run Code Online (Sandbox Code Playgroud)
并且我在开发环境中运行测试或提供页面时没有这样的错误,只有当我运行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"}开关,一切都按预期工作.
将其添加到config/config.ex
config :adah, :ecto_repos, [Adah.Repo]
Run Code Online (Sandbox Code Playgroud)