Merge remote-tracking branch 'pleroma/develop' into features/poll-validation
[akkoma] / priv / repo / migrations / 20200722185515_fix_malformed_formatter_config.exs
1 defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfig do
2 use Ecto.Migration
3 alias Pleroma.ConfigDB
4
5 @config_path %{group: :pleroma, key: Pleroma.Formatter}
6
7 def change do
8 with %ConfigDB{value: %{} = opts} <- ConfigDB.get_by_params(@config_path),
9 fixed_opts <- Map.to_list(opts) do
10 fix_config(fixed_opts)
11 else
12 _ -> :skipped
13 end
14 end
15
16 defp fix_config(fixed_opts) when is_list(fixed_opts) do
17 {:ok, _} =
18 ConfigDB.update_or_create(%{
19 group: :pleroma,
20 key: Pleroma.Formatter,
21 value: fixed_opts
22 })
23
24 :ok
25 end
26 end