Ecto migration fails on Heroku

ecto
phoenix
deployment

#1

I’ve got a new app deployed to Heroku and am unable to get the Repo application to start.

In prod.exs:

use Mix.Config


config :testapp, TestappWeb.Endpoint,
  url: [scheme: "https", host: System.get_env("BASE_URL"), port: 443],
  force_ssl: [rewrite_on: [:x_forwarded_proto]],
  http: [:inet6, port: System.get_env("PORT") || 4000],
  cache_static_manifest: "priv/static/cache_manifest.json",
  secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")

# Do not print debug messages in production
config :logger, level: :info

config :testapp, Testapp.Repo,
  url: System.get_env("DATABASE_URL"),
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  ssl: true

[...snip...]

But trying to connect to the app or run ecto.migrate gives the following error:

** (EXIT from #PID<0.74.0>) an exception was raised:
      ** (ArgumentError) supervisors expect the child to be a module, a {module, arg} tuple or a map with the child specification, got:
       {DBConnection.ConnectionPool, {Ecto.Repo.Supervisor, :start_child, [{DBConnection.ConnectionPool, :start_link, [{Postgrex.Protocol, [types:
        Postgrex.DefaultTypes, repo: Testapp.Repo, telemetry_prefix: [:Testapp, :repo], otp_app: :Testapp, timeout: 15000, pool_timeout: 5000, adapter:
         Ecto.Adapters.Postgres, ssl: true, pool_size: 2, username: "...", password: "...", database: "...", hostname: "...", port: 5432, pool:
          DBConnection.ConnectionPool]}]}, Ecto.Adapters.Postgres, #Reference<0.280083182.1810497537.168308>, %{opts: [timeout: 15000, pool_timeout: 5000,
           pool_size: 2, pool: DBConnection.ConnectionPool], sql: Ecto.Adapters.Postgres.Connection, telemetry: {:debug, [], [:Testapp, :repo, :query]}}]},
            :permanent, 5000, :worker, [DBConnection.ConnectionPool]}
        (elixir) lib/supervisor.ex:609: Supervisor.init_child/1
        (elixir) lib/enum.ex:1255: Enum."-map/2-lists^map/1-0-"/2
        (elixir) lib/supervisor.ex:581: Supervisor.init/2
        (stdlib) supervisor.erl:294: :supervisor.init/1
        (stdlib) gen_server.erl:365: :gen_server.init_it/2
        (stdlib) gen_server.erl:333: :gen_server.init_it/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3a

Any suggestions as to what I might be doing wrong or overlooking? As far as I can tell I’ve followed the Phoenix Heroku setup instructions correctly.

Edit: added error instead of another copy of the config file :man_facepalming:


#2

Can you post the error message that you receive?


#3

Sure, fixed that.


#4

What is your Elixir version configured on Heroku? Are you on latest?


#5

Also please let us know your Ecto version.


#6

@josevalim Turns out it was Elixir 1.5.0. I’ve upgraded to Erlang 21.1.2 & Elixir v1.7.4 and it now works as expected.

Also, it was ecto 3.0.3 & ecto_sql 3.0.2.


#7

I thought it was the Elixir version because I remembered Elixir v1.5.0 had a bug where the tuple child specs were not allowed at some positions. :slight_smile:


#8

It would probably have taken me a long time to have thought to check that. Thanks for your help!


#9

glad i ran into this post here. this is kind of unfortunate since I was following the exact steps from Phoenix docs https://hexdocs.pm/phoenix/heroku.html.

This guide does not mention elixir_buildpack.config file how to set the Erlang and Elixir versions on heroku. I found this instruction to be most useful and successfully deployed the app.

Thanks again for all the work!