elixir - 使用 Ecto 2.0.0-rc.0 并执行 ecto.migrate 时出现奇怪的错误

标签 elixir phoenix-framework ecto

今天,和往常一样,我尝试制作 混合 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/

相关文章:

postgresql - 使用具有 has_many 关系的结构为数据库播种时找不到列

elixir - 为什么我得到#Ecto.Association.NotLoaded?

metaprogramming - case 表达式中的 `unquote` 和 `binding_quote`

arrays - Ecto 查询 Postgres JSON 数组的值

erlang - 如何在 elixir 中将 erlang 错误消息翻译成用户友好的文本

postgresql - (Postgrex.Error) 错误 58P01 (undefined_file)

elixir - 加入 Phoenix Channel(或其他 pubsub)时同步应用程序状态

bootstrap-modal - 如何将 Bootstrap 模态组件与 Phoenix 集成?

postgresql - 检查数据库中的 "now()"和时间戳是否与 3 天不同

elixir - UndefinedFunctionError - phoenix/ecto 中的 iex 别名