mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
moving to mrf namespace migration fix
This commit is contained in:
parent
c7d69e9256
commit
cb96c82f70
1 changed files with 10 additions and 10 deletions
|
@ -5,13 +5,11 @@ defmodule Pleroma.Repo.Migrations.MrfConfigMoveFromInstanceNamespace do
|
|||
|
||||
@old_keys [:rewrite_policy, :mrf_transparency, :mrf_transparency_exclusions]
|
||||
def change do
|
||||
config = ConfigDB.get_by_params(%{group: ":pleroma", key: ":instance"})
|
||||
config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
|
||||
if config do
|
||||
old_instance = ConfigDB.from_binary(config.value)
|
||||
|
||||
mrf =
|
||||
old_instance
|
||||
config.value
|
||||
|> Keyword.take(@old_keys)
|
||||
|> Keyword.new(fn
|
||||
{:rewrite_policy, policies} -> {:policies, policies}
|
||||
|
@ -21,15 +19,17 @@ defmodule Pleroma.Repo.Migrations.MrfConfigMoveFromInstanceNamespace do
|
|||
|
||||
if mrf != [] do
|
||||
{:ok, _} =
|
||||
ConfigDB.create(
|
||||
%{group: ":pleroma", key: ":mrf", value: ConfigDB.to_binary(mrf)},
|
||||
false
|
||||
)
|
||||
%ConfigDB{}
|
||||
|> ConfigDB.changeset(%{group: :pleroma, key: :mrf, value: mrf})
|
||||
|> Pleroma.Repo.insert()
|
||||
|
||||
new_instance = Keyword.drop(old_instance, @old_keys)
|
||||
new_instance = Keyword.drop(config.value, @old_keys)
|
||||
|
||||
if new_instance != [] do
|
||||
{:ok, _} = ConfigDB.update(config, %{value: ConfigDB.to_binary(new_instance)}, false)
|
||||
{:ok, _} =
|
||||
config
|
||||
|> ConfigDB.changeset(%{value: new_instance})
|
||||
|> Pleroma.Repo.update()
|
||||
else
|
||||
{:ok, _} = ConfigDB.delete(config)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue