diff options
author | lain <lain@soykaf.club> | 2020-11-20 16:26:22 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-11-20 16:26:22 +0100 |
commit | a407e33c78121abf880f257d291f45ed28b55eeb (patch) | |
tree | f0c033991472bd6392de0e3375345635b3860fb7 | |
parent | 5e04f4156ce64e5be633fce19c56bec0d93f53bf (diff) | |
download | pleroma-a407e33c78121abf880f257d291f45ed28b55eeb.tar.gz |
Application: Save postgres version in the environment
-rw-r--r-- | lib/pleroma/application.ex | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex index 8f08a6222..f2a8c7825 100644 --- a/lib/pleroma/application.ex +++ b/lib/pleroma/application.ex @@ -109,7 +109,28 @@ defmodule Pleroma.Application do # See http://elixir-lang.org/docs/stable/elixir/Supervisor.html # for other strategies and supported options opts = [strategy: :one_for_one, name: Pleroma.Supervisor] - Supervisor.start_link(children, opts) + result = Supervisor.start_link(children, opts) + + set_postgres_server_version() + + result + end + + defp set_postgres_server_version() do + version = + with %{rows: [[version]]} <- Ecto.Adapters.SQL.query!(Pleroma.Repo, "show server_version"), + {num, _} <- Float.parse(version) do + num + else + e -> + Logger.warn( + "Could not get the postgres version: #{inspect(e)}.\nSetting the default value of 9.6" + ) + + 9.6 + end + + Application.put_env(:postgres, :version, version) end def load_custom_modules do |