Is Phoenix 1.3 reading the database adapter correctly?

Using the mnesia_ecto adapter works in my Phoenix 1.2 app:

# in dev.exs
# Configure your database
config :foo, Foo.Repo,
  adapter: Ecto.Adapters.Mnesia
...

But in 1.3 I am getting these errors:

~/projects/current/foo_server/apps/foo$ mix ecto.create
** (KeyError) key :database not found in: [otp_app: :foo, repo: Foo.Repo, adapter: Ecto.Adapters.Mnesia]
    (elixir) lib/keyword.ex:343: Keyword.fetch!/2
    lib/ecto/adapters/postgres.ex:111: Ecto.Adapters.Postgres.storage_up/1
    lib/mix/tasks/ecto.create.ex:36: anonymous fn/3 in Mix.Tasks.Ecto.Create.run/1
    (elixir) lib/enum.ex:645: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:645: Enum.each/2
    (mix) lib/mix/task.ex:294: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

~/projects/current/foo_server/apps/foo$ mix ecto.migrate
** (UndefinedFunctionError) function DBConnection.ensure_all_started/2 is undefined (module DBConnection is not available)
    DBConnection.ensure_all_started([pool_timeout: 5000, timeout: 15000, adapter: Ecto.Adapters.Postgres, pool: DBConnection.Poolboy], :temporary)
    (ecto) lib/ecto/adapters/postgres.ex:86: Ecto.Adapters.Postgres.ensure_all_started/2
    (ecto) lib/mix/ecto.ex:84: Mix.Ecto.ensure_started/2
    (ecto) lib/mix/tasks/ecto.migrate.ex:72: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
    (elixir) lib/enum.ex:645: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:645: Enum.each/2
    (mix) lib/mix/task.ex:294: Mix.Task.run_task/3
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2

It looks like it is still trying to call the postgres adapter. I am pretty sure I did this the same as my other app, and I didn’t read any changes on this the change notes.

1 Like

@rschooley: Can you re-check you configuration and repository module?
From what I can see in: lib/mix/tasks/ecto.create.ex:36 there is:

case repo.__adapter__.storage_up(repo.config) do

so Ecto is reading your __adapter__ that is set to postgres, please see next line in your stacktrace: lib/ecto/adapters/postgres.ex:111.
Alternatively try to update Ecto - maybe you are using old version of it?