Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into websearch
[akkoma] / lib / pleroma / application.ex
index ced14f87ff510b68b9531f263b400b16cdd234c5..22936bd7f245e7f7c128b1c7581c0f87bd4d4d82 100644 (file)
@@ -110,7 +110,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