diff --git a/config/runtime.exs b/config/runtime.exs index 51b072f7c..3d4bdd620 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -1,18 +1,5 @@ import Config -if config_env() == :dev do - {ssl, ssl_opts} = - if System.get_env("DATABASE_URL") do - {true, [verify: :verify_none]} - else - {false, []} - end - - config :sanbase, Sanbase.Repo, - ssl: ssl, - ssl_opts: ssl_opts -end - if config_env() in [:dev, :test] do # In order to properly work while developing locally, # load the .env file before doing the configuration diff --git a/lib/sanbase/repo.ex b/lib/sanbase/repo.ex index 6f135195d..52aae1974 100644 --- a/lib/sanbase/repo.ex +++ b/lib/sanbase/repo.ex @@ -15,6 +15,17 @@ defmodule Sanbase.Repo do |> Keyword.put(:pool_size, pool_size) |> Keyword.put(:url, System.get_env("DATABASE_URL")) + test_env? = Application.get_env(:sanbase, :env) == :test + + opts = + if is_nil(System.get_env("DATABASE_URL")) or test_env? do + opts + else + opts + |> Keyword.put(:ssl, true) + |> Keyword.put(:ssl_opts, verify: :verify_none) + end + {:ok, opts} end end