diff options
Diffstat (limited to 'priv/repo')
| -rw-r--r-- | priv/repo/migrations/20200716195806_autolinker_to_linkify.exs | 7 | ||||
| -rw-r--r-- | priv/repo/migrations/20200722185515_fix_malformed_formatter_config.exs | 26 | 
2 files changed, 29 insertions, 4 deletions
| diff --git a/priv/repo/migrations/20200716195806_autolinker_to_linkify.exs b/priv/repo/migrations/20200716195806_autolinker_to_linkify.exs index 9ec4203eb..570acba84 100644 --- a/priv/repo/migrations/20200716195806_autolinker_to_linkify.exs +++ b/priv/repo/migrations/20200716195806_autolinker_to_linkify.exs @@ -1,7 +1,5 @@  defmodule Pleroma.Repo.Migrations.AutolinkerToLinkify do    use Ecto.Migration - -  alias Pleroma.Repo    alias Pleroma.ConfigDB    @autolinker_path %{group: :auto_linker, key: :opts} @@ -23,15 +21,16 @@ defmodule Pleroma.Repo.Migrations.AutolinkerToLinkify do    defp maybe_get_params() do      with %ConfigDB{value: opts} <- ConfigDB.get_by_params(@autolinker_path), -         %{} = opts <- transform_opts(opts), +         opts <- transform_opts(opts),           %{} = linkify_params <- Map.put(@linkify_path, :value, opts) do        {:ok, {@autolinker_path, linkify_params}}      end    end -  defp transform_opts(opts) when is_list(opts) do +  def transform_opts(opts) when is_list(opts) do      opts      |> Enum.into(%{})      |> Map.take(@compat_opts) +    |> Map.to_list()    end  end diff --git a/priv/repo/migrations/20200722185515_fix_malformed_formatter_config.exs b/priv/repo/migrations/20200722185515_fix_malformed_formatter_config.exs new file mode 100644 index 000000000..77b760825 --- /dev/null +++ b/priv/repo/migrations/20200722185515_fix_malformed_formatter_config.exs @@ -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 | 
