1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Repo.Migrations.SimplePolicyStringToTuple do
10 def up, do: ConfigDB.get_by_params(%{group: :pleroma, key: :mrf_simple}) |> update_to_tuples
11 def down, do: ConfigDB.get_by_params(%{group: :pleroma, key: :mrf_simple}) |> update_to_strings
13 defp update_to_tuples(%{value: value}) do
16 |> Enum.map(fn {k, v} ->
19 {instance, reason} -> {instance, reason}
20 instance -> {instance, ""}
24 ConfigDB.update_or_create(%{group: :pleroma, key: :mrf_simple, value: new_value})
27 defp update_to_tuples(nil), do: {:ok, nil}
29 defp update_to_strings(%{value: value}) do
32 |> Enum.map(fn {k, v} ->
35 {instance, _} -> instance
40 ConfigDB.update_or_create(%{group: :pleroma, key: :mrf_simple, value: new_value})
43 defp update_to_strings(nil), do: {:ok, nil}