summaryrefslogtreecommitdiff
path: root/priv
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-09-05 12:41:01 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-09-07 19:59:17 +0300
commit8a3d43044a06488545490a89e29c8349d914f164 (patch)
tree85c3a4fa535748b0e550437f886a41436273861d /priv
parenta83916fdacac7b11ca478ef9a61b32dd269c8fd2 (diff)
migrations for renaming gun timeout options
Diffstat (limited to 'priv')
-rw-r--r--priv/repo/migrations/20200905082737_rename_await_up_timeout_in_connections_pool.exs13
-rw-r--r--priv/repo/migrations/20200905091427_rename_timeout_in_pools.exs19
2 files changed, 32 insertions, 0 deletions
diff --git a/priv/repo/migrations/20200905082737_rename_await_up_timeout_in_connections_pool.exs b/priv/repo/migrations/20200905082737_rename_await_up_timeout_in_connections_pool.exs
new file mode 100644
index 000000000..22c40663c
--- /dev/null
+++ b/priv/repo/migrations/20200905082737_rename_await_up_timeout_in_connections_pool.exs
@@ -0,0 +1,13 @@
+defmodule Pleroma.Repo.Migrations.RenameAwaitUpTimeoutInConnectionsPool do
+ use Ecto.Migration
+
+ def change do
+ with %Pleroma.ConfigDB{} = config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: :connections_pool}),
+ {timeout, value} when is_integer(timeout) <- Keyword.pop(config.value, :await_up_timeout) do
+ config
+ |> Ecto.Changeset.change(value: Keyword.put(value, :connect_timeout, timeout))
+ |> Pleroma.Repo.update()
+ end
+ end
+end
diff --git a/priv/repo/migrations/20200905091427_rename_timeout_in_pools.exs b/priv/repo/migrations/20200905091427_rename_timeout_in_pools.exs
new file mode 100644
index 000000000..bb2f50ecc
--- /dev/null
+++ b/priv/repo/migrations/20200905091427_rename_timeout_in_pools.exs
@@ -0,0 +1,19 @@
+defmodule Pleroma.Repo.Migrations.RenameTimeoutInPools do
+ use Ecto.Migration
+
+ def change do
+ with %Pleroma.ConfigDB{} = config <-
+ Pleroma.ConfigDB.get_by_params(%{group: :pleroma, key: :pools}) do
+ updated_value =
+ Enum.map(config.value, fn {pool, pool_value} ->
+ with {timeout, value} when is_integer(timeout) <- Keyword.pop(pool_value, :timeout) do
+ {pool, Keyword.put(value, :recv_timeout, timeout)}
+ end
+ end)
+
+ config
+ |> Ecto.Changeset.change(value: updated_value)
+ |> Pleroma.Repo.update()
+ end
+ end
+end