Error compiling for production

When compiling for deployment I get this error when trying to read some value from the database in a plug. Plug is then linked to pipeline.

** (RuntimeError) could not lookup Ecto repo Ucms.Repo because it was not started or it does not exist

In test environment it compiles and works fine.

Regards,
Gregor

pipeline :web do
    plug :put_root_layout, {UcmsWeb.LayoutView, :web}
    plug :put_layout, {UcmsWeb.LayoutView, :blank}
    plug UcmsWeb.Plugs.GoogleAnalytics
end
defmodule UcmsWeb.Plugs.GoogleAnalytics do
  import Plug.Conn

  alias Ucms.Content

  def init(opts) do
    case Mix.env() do
        :prod ->
            ga_id = Content.get_config_value_by_key("google_analytics")
            Keyword.put(opts, :ga_id, ga_id)
        :dev ->
            ga_id = Content.get_config_value_by_key("google_analytics")
            Keyword.put(opts, :ga_id, ga_id)
        :test ->
            ga_id = ""
            Keyword.put(opts, :ga_id, ga_id)
    end
  end

  def call(conn, ga_id: ga_id), do: assign(conn, :ga_id, ga_id)
  def call(conn, _opts), do: conn
end

Plug works differently in production - your init functions run at compile time. Does Content.get_config_value_by_key query the database? (sounds like it, based on the error)

Yes it reads a value from DB.