From 75ea766824a5d7714fbea5d24e59444c7adfc274 Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 21 Feb 2022 09:38:38 +0100 Subject: [PATCH] Migration failed when no value for Pleroma.Upload was set --- ...lter_exiftool_to_exiftool_strip_location.exs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs b/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs index 7afb7479a..0878b9699 100644 --- a/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs +++ b/priv/repo/migrations/20220220135625_upload_filter_exiftool_to_exiftool_strip_location.exs @@ -20,15 +20,18 @@ def down, ) defp update_filtername(%{value: value}, from_filtername, to_filtername) do - new_filters = - value[:filters] - |> Enum.map(fn - ^from_filtername -> to_filtername - filter -> filter + new_value = + value + |> Keyword.update(:filters, [], fn filters -> + filters + |> Enum.map(fn + ^from_filtername -> to_filtername + filter -> filter + end) end) - new_value = value |> Keyword.update(:filters, [], fn _ -> new_filters end) - ConfigDB.update_or_create(%{group: :pleroma, key: Pleroma.Upload, value: new_value}) end + + defp update_filtername(_, _, _), do: nil end