Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange error while using Ecto 2.0.0-rc.0 and executing ecto.migrate

Today, as often, I tried to make mix ecto.migrate in my Phoenix application and surprisingly found the following error:

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

My deps are:

phoenix_ecto: 3.0.0-rc.0
ecto: 2.0.0-rc.0
...

My config files have the following lines:

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

And I have no such errors while running tests or serving pages in dev environment, only when I run mix ecto.migrate.

So... what should I add to my config files or pass in to -r flag?

UPDATE: I believe there is a bug and it's corresponding to phoenix-3.0.0-rc.0 or ecto-2.0.0-rc.0 packages, because when I use {:ecto, "== 2.0.0-beta.2", :phoenix_ecto, "3.0.0-beta.2"} switches, everything works as expected.

like image 406
Valentin T. Avatar asked Apr 17 '16 19:04

Valentin T.


1 Answers

Add this to config/config.ex

config :adah, :ecto_repos, [Adah.Repo]
like image 108
Andrew Avatar answered Sep 19 '22 05:09

Andrew