I'm creating a simple API Rest using Phoenix. I am getting the following error when executing the command: mix ecto.migrate
22:25:14.197 [error] Postgrex.Protocol (#PID<0.193.0>) failed to connect: ** (Postgrex.Error) FATAL (invalid_catalog_name): database "api_example_dev" does not exist
** (DBConnection.ConnectionError) connection not available because of disconnection
(db_connection) lib/db_connection.ex:934: DBConnection.checkout/2
(db_connection) lib/db_connection.ex:750: DBConnection.run/3
(db_connection) lib/db_connection.ex:1141: DBConnection.run_meter/3
(db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
(ecto) lib/ecto/adapters/postgres/connection.ex:91: Ecto.Adapters.Postgres.Connection.execute/4
(ecto) lib/ecto/adapters/sql.ex:235: Ecto.Adapters.SQL.sql_call/6
(ecto) lib/ecto/adapters/sql.ex:185: Ecto.Adapters.SQL.query!/5
(ecto) lib/ecto/adapters/postgres.ex:71: Ecto.Adapters.Postgres.execute_ddl/3
(ecto) lib/ecto/migrator.ex:43: Ecto.Migrator.migrated_versions/2
(ecto) lib/ecto/migrator.ex:142: Ecto.Migrator.run/4
(ecto) lib/mix/tasks/ecto.migrate.ex:84: anonymous fn/4 in Mix.Tasks.Ecto.Migrate.run/2
(elixir) lib/enum.ex:737: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:737: Enum.each/2
(mix) lib/mix/task.ex:314: Mix.Task.run_task/3
(mix) lib/mix/cli.ex:80: Mix.CLI.run_task/2
(elixir) lib/code.ex:677: Code.require_file/2
When I run 'mix test', I get:
Generated api_example app
** (Mix) The database for ApiExample.Repo couldn't be created: exited in: :gen_server.call(#PID<0.2449.0>, {:checkout, #Reference<0.2107810362.96468993.2762>, true, 15000}, 5000)
** (EXIT) time out
22:24:29.587 [error] Task #PID<0.2448.0> started from #PID<0.74.0> terminating
** (stop) exited in: :gen_server.call(#PID<0.2449.0>, {:checkout, #Reference<0.2107810362.96468993.2762>, true, 15000}, 5000)
** (EXIT) time out
(db_connection) lib/db_connection/connection.ex:54: DBConnection.Connection.checkout/2
(db_connection) lib/db_connection.ex:928: DBConnection.checkout/2
(db_connection) lib/db_connection.ex:750: DBConnection.run/3
(db_connection) lib/db_connection.ex:1141: DBConnection.run_meter/3
(db_connection) lib/db_connection.ex:592: DBConnection.prepare_execute/4
lib/ecto/adapters/postgres/connection.ex:91: Ecto.Adapters.Postgres.Connection.execute/4
lib/ecto/adapters/postgres.ex:203: anonymous fn/2 in Ecto.Adapters.Postgres.run_query/2
(elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
Function: #Function<4.100334649/0 in Ecto.Adapters.Postgres.run_query/2>
file config/dev.exs:
# Configure your database
config :api_example, ApiExample.Repo,
adapter: Ecto.Adapters.Postgres,
username: "postgres",
password: "postgres",
database: "api_example_dev",
hostname: "localhost",
pool_size: 10
mix ecto.create
first? – Kitchenlocalhost
in the first place? – Yama