Migration to fix malformed Pleroma.Formatter config
This commit is contained in:
parent
b87a1f8eaf
commit
c7a0016f9f
2 changed files with 88 additions and 0 deletions
|
|
@ -0,0 +1,26 @@
|
|||
defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfig do
|
||||
use Ecto.Migration
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
@config_path %{group: :pleroma, key: Pleroma.Formatter}
|
||||
|
||||
def change do
|
||||
with %ConfigDB{value: %{} = opts} <- ConfigDB.get_by_params(@config_path),
|
||||
fixed_opts <- Map.to_list(opts) do
|
||||
fix_config(fixed_opts)
|
||||
else
|
||||
_ -> :skipped
|
||||
end
|
||||
end
|
||||
|
||||
defp fix_config(fixed_opts) when is_list(fixed_opts) do
|
||||
{:ok, _} =
|
||||
ConfigDB.update_or_create(%{
|
||||
group: :pleroma,
|
||||
key: Pleroma.Formatter,
|
||||
value: fixed_opts
|
||||
})
|
||||
|
||||
:ok
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue