Failed Ecto migration does not generate stack trace in app logs

Hi, I noticed strange problem in my Elixir app, whenever I run new migration on production env I get no feedback and the application starts despite the fact that migration actually failed. Checking app logs right after deploy reveala nothing, there is not stack trace in the logs.

Only running migrations via:

Ecto.Migrator.run(MyApp.Repo, :up, all: true)

in remote iex console on prod reveals stack trace and what is actually wrong with the migration, this is obviously undesired behaviour. The interesting thing is that it only happens with one of our Elixir apps, other Elixir apps fail properly on migration error.

Any ideas how to debug this, I tried:

  def migrate do
    load_app()
    Logger.info("Running migrations")

    for repo <- repos() do
      case Ecto.Migrator.with_repo(repo, &Ecto.Migrator.run(&1, :up, all: true)) do
        {:ok, _, _} -> Logger.info("Migrations run successfully")
        {:error, term} -> Logger.error("Error running migrations: #{inspect(term)}")
      end
    end
  end

but neither 1{:ok, ...} nor {:error, …}` was printed :man_shrugging:.

How do you call that migrate/0 function?

It is called via shell script:

#!/bin/sh
cd -P -- "$(dirname -- "$0")"
exec ./our_app_name eval OurApp.Release.migrate

and that script is located in:

rel/overlays/bin/migrate